RadarChartEngineTests.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using Masuit.Tools.Maths;
  4. using Xunit;
  5. namespace Masuit.Tools.Abstractions.Test.Maths;
  6. public class RadarChartEngineTests
  7. {
  8. [Fact]
  9. public void ComputeArea_ShouldReturnCorrectArea()
  10. {
  11. var points = new List<Point2D>
  12. {
  13. new Point2D(0, 0),
  14. new Point2D(4, 0),
  15. new Point2D(4, 3),
  16. new Point2D(0, 3)
  17. };
  18. var area = points.ComputeArea();
  19. Assert.Equal(12, area, 6);
  20. }
  21. [Fact]
  22. public void ComputeIntersection_ShouldReturnCorrectIntersection()
  23. {
  24. var firstChart = new RadarChart(new List<double> { 3, 4, 5 }, 0);
  25. var secondChart = new RadarChart(new List<double> { 5, 3, 4 }, 0);
  26. var intersection = firstChart.ComputeIntersection(secondChart);
  27. Assert.NotNull(intersection);
  28. Assert.Equal(5, intersection.Count);
  29. }
  30. [Fact]
  31. public void ComputeIntersection_ShouldThrowExceptionForDifferentStartAngles()
  32. {
  33. var firstChart = new RadarChart(new List<double> { 3, 4, 5 }, 0);
  34. var secondChart = new RadarChart(new List<double> { 5, 3, 4 }, 1);
  35. Assert.Throws<ArgumentException>(() => firstChart.ComputeIntersection(secondChart));
  36. }
  37. [Fact]
  38. public void ComputeIntersection_ShouldThrowExceptionForDifferentDataCounts()
  39. {
  40. var firstChart = new RadarChart(new List<double> { 3, 4, 5 }, 0);
  41. var secondChart = new RadarChart(new List<double> { 5, 3 }, 0);
  42. Assert.Throws<ArgumentException>(() => firstChart.ComputeIntersection(secondChart));
  43. }
  44. }