public void FillColoredTriangleTest1() { var expected = Color.Orange; ColoredTriangle coloredTriangle = new ColoredTriangle() { Brush = new SolidBrush(expected), Vertices = new Point[] { new Point(-1, -1), new Point(-1, 2), new Point(2, -1) } }; using (var bitmap = new Bitmap(1, 1)) { using (var graphics = Graphics.FromImage(bitmap)) { GraphicsExtensions.FillColoredTriangle(graphics, coloredTriangle); } var actual = bitmap.GetPixel(0, 0); Assert.AreEqual(expected.R, actual.R); Assert.AreEqual(expected.G, actual.G); Assert.AreEqual(expected.B, actual.B); } }
public void EqualsColoredTriangleTest2() { ColoredTriangle target = new ColoredTriangle(); ColoredTriangle other = new ColoredTriangle(); bool expected = true; bool actual; actual = target.Equals(other); Assert.AreEqual(expected, actual); }
public void EqualsTest() { ColoredTriangle target = new ColoredTriangle(); object other = null; bool expected = false; bool actual; actual = target.Equals(other); Assert.AreEqual(expected, actual); }
public void BrushTest() { ColoredTriangle target = new ColoredTriangle(); Brush expected = null; Brush actual; target.Brush = expected; actual = target.Brush; Assert.AreEqual(expected, actual); }
public void VerticesTest2() { ColoredTriangle target = new ColoredTriangle(); var input = new Point[] { new Point(0, 0), new Point(0, 1), new Point(1, 0) }; var expected = input; target.Vertices = expected; var actual = target.Vertices; Assert.AreEqual(expected, actual); }
public void VerticesTest3() { ColoredTriangle target = new ColoredTriangle(); Point[] input = new Point[] { new Point(0, 0), new Point(0, 1), new Point(0, 2) }; Point[] expected = null; target.Vertices = input; var actual = target.Vertices; Assert.AreEqual(expected, actual); }
public void VerticesTest1() { ColoredTriangle target = new ColoredTriangle(); Point[] input = null; var expected = input; target.Vertices = expected; var actual = target.Vertices; Assert.AreEqual(expected, actual); }
public void EqualsColoredTriangleTest9() { ColoredTriangle target = new ColoredTriangle() { Vertices = new Point[] { new Point(0, 1), new Point(1, 1), new Point(0, 0) } }; ColoredTriangle other = target; bool expected = true; bool actual = target.Equals(other); Assert.AreEqual(expected, actual); }
public void TestParseValidTriangle() { var coloredTriangle = ColoredTriangle.Parse("Red-7:Blue-8:Orange-4"); var expectedTriangle = new ColoredTriangle { FirstSide = new ColoredSide(Color.Red, 7), SecondSide = new ColoredSide(Color.Blue, 8), ThirdSide = new ColoredSide(Color.Orange, 4) }; Assert.AreEqual(coloredTriangle, expectedTriangle); }
/// <summary> /// This function reads ColoredTriangle objects and puts them into a sorted list. /// The key of the sorted list is the perimeter of the corresponding triangle /// </summary> /// <param name="fileName">The name of the file</param> /// <returns>Returns the sorted list of objects of ColoredTriangle class</returns> public static SortedList <double, ColoredTriangle> ReadTrianglesToSortedList(string fileName) { var coloredTriangles = new SortedList <double, ColoredTriangle>(); foreach (var triangleString in File.ReadAllLines(fileName)) { var triangle = ColoredTriangle.Parse(triangleString); coloredTriangles.Add(triangle.Perimeter(), triangle); } return(coloredTriangles); }
public void EqualsColoredTriangleTest3() { ColoredTriangle target = new ColoredTriangle() { Brush = Brushes.AliceBlue }; ColoredTriangle other = new ColoredTriangle(); bool expected = false; bool actual; actual = target.Equals(other); Assert.AreEqual(expected, actual); }
private static List <ColoredTriangle> ProvideTriangles() { return(new List <ColoredTriangle> { ColoredTriangle.Parse("Red-2:Blue-2:Red-3"), ColoredTriangle.Parse("Black-8:Green-6:Purple-13"), ColoredTriangle.Parse("Yellow-4:Yellow-6:Red-3"), ColoredTriangle.Parse("Green-6:Green-10:Green-15"), ColoredTriangle.Parse("Orange-6:Yellow-9:Green-4"), ColoredTriangle.Parse("Orange-10:Orange-25:Orange-20"), ColoredTriangle.Parse("Red-6:Green-8:Blue-3"), ColoredTriangle.Parse("Red-4:Blue-4:Blue-4"), ColoredTriangle.Parse("Green-14:Green-20:Green-7") }); }
public void Enumeration() { ColoredTriangle t1 = new ColoredTriangle(Color.Black, TriangleFixture.ConstructTriangle()); ColoredTriangle t2 = new ColoredTriangle(Color.White, TriangleFixture.ConstructTriangle()); ColoredTriangleSoup soup = new ColoredTriangleSoup(); soup.Add(t1); soup.Add(t2); List<ColoredTriangle> expected = new List<ColoredTriangle>(); expected.Add(t1); expected.Add(t2); List<ColoredTriangle> result = new List<ColoredTriangle>(); foreach (ColoredTriangle tri in soup) result.Add(tri); CollectionAssert.AreEqual(expected, result); }
public void TestEqualsAndHashCode() { var side1 = new ColoredSide(Color.Red, 7); var side2 = new ColoredSide(Color.Blue, 6); var side3 = new ColoredSide(Color.Yellow, 5); var triangle = new ColoredTriangle { FirstSide = side1, SecondSide = side2, ThirdSide = side3 }; var triangle2 = new ColoredTriangle { FirstSide = side1, SecondSide = side2, ThirdSide = side3 }; Assert.IsTrue(triangle.Equals(triangle2)); Assert.AreEqual(triangle.GetHashCode(), triangle2.GetHashCode()); }
public void TestParseInvalidTriangleSidesLength() { Assert.Throws <DomainException>(() => ColoredTriangle.Parse("Red-1:Blue-2:Orange-3")); }
public void TestParseInvalidTriangleFormat() { Assert.Throws <DomainException>(() => ColoredTriangle.Parse("Rdd-43:Blue-23")); }
protected bool Equals(ColoredTriangle other) { return(FirstSide.Equals(other.FirstSide) && SecondSide.Equals(other.SecondSide) && ThirdSide.Equals(other.ThirdSide)); }
public void Map() { ColoredTriangle t1 = new ColoredTriangle(Color.Black, TriangleFixture.ConstructTriangle()); ColoredTriangle t2 = new ColoredTriangle(Color.White, TriangleFixture.ConstructTriangle()); ColoredTriangleSoup soup = new ColoredTriangleSoup(); soup.Add(t1); soup.Add(t2); soup.Map(delegate(ColoredTriangle triangle) { return new ColoredTriangle(Color.Yellow, triangle.Triangle); }); List<ColoredTriangle> expected = new List<ColoredTriangle>(); ColoredTriangle t1b = new ColoredTriangle(Color.Yellow, TriangleFixture.ConstructTriangle()); ColoredTriangle t2b = new ColoredTriangle(Color.Yellow, TriangleFixture.ConstructTriangle()); expected.Add(t1b); expected.Add(t2b); List<ColoredTriangle> result = new List<ColoredTriangle>(); foreach (ColoredTriangle tri in soup) result.Add(tri); CollectionAssert.AreEqual(expected, result); }
public void AccessTriangle() { ColoredTriangle newTriangle = new ColoredTriangle(Color.Red, TriangleFixture.ConstructTriangle()); cts.Add(newTriangle); Assert.AreEqual(newTriangle, cts[1]); }
public void ReplaceTriangle() { ColoredTriangle newTriangle = new ColoredTriangle(Color.Red, TriangleFixture.ConstructTriangle()); cts[0] = newTriangle; Assert.AreEqual(newTriangle, cts[0]); }
public void ColoredTriangleConstructorTest() { ColoredTriangle target = new ColoredTriangle(); }