IgnoreExtensions-nef
Config-LoadPhotoPrismLocations TestMethodIntersect
This commit is contained in:
@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
@ -307,4 +308,74 @@ public partial class UnitTestCalculations
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodIntersect()
|
||||
{
|
||||
float? percent;
|
||||
float? areaA = null;
|
||||
RectangleF rectangleA;
|
||||
RectangleF rectangleB;
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == 1);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(0, 0, 2, 2);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .25);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(0, 0, 4, 2);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .5);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(2, 2, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .25);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(2, 0, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .5);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
rectangleB = new(2, 4, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == 0);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(0, 0, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == 1);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(0, 0, 2, 2);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .25);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(0, 0, 4, 2);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .5);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(2, 2, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .25);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(2, 0, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == .5);
|
||||
rectangleB = new(0, 0, 4, 4);
|
||||
rectangleA = new(2, 4, 4, 4);
|
||||
percent = ILocation.GetIntersectPercent(rectangleA, areaA, rectangleB);
|
||||
Assert.IsNotNull(percent);
|
||||
Assert.IsTrue(percent.Value == 0);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user