WIP: TU_Dice #183

Closed
ismail.taha_janan wants to merge 5 commits from TU_Dice into main

@ -0,0 +1,55 @@
using Model.Dice.Faces;
using Model.Dice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using System.Drawing;
namespace Tests.Model_UTs.Dice
{
public class ColorDieTest
{
public static IEnumerable<object[]> Data_Uri()
{
yield return new object[]
{
new ColorFace(Color.FromName("Chocolate")),
new ColorFace(Color.FromName("Aqua")),
new ColorFace(Color.FromName("Beige")),
new ColorFace(Color.FromName("Black")),
new ColorFace(Color.FromName("BurlyWood")),
};
}
[Theory]
[MemberData(nameof(Data_Uri))]
public void RndmFaceTest(ColorFace f1, ColorFace f2, ColorFace f3, ColorFace f4, ColorFace f5)
{
//Arrange
List<ColorFace> listFaces = new() {
f1,f2,f3,f4,f5
};
ColorDie die = new(
listFaces[1],
listFaces[2],
listFaces[3],
listFaces[4]
);
//Act
ColorFace actual = (ColorFace)die.GetRandomFace();
//Assert
Assert.Contains(listFaces, face => face == actual);
}
}
}

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Model.Dice.Faces;
using System.Drawing;
namespace Tests.Model_UTs.Dice.Faces
{
public class FaceColorTest
{
public static IEnumerable<object[]> Data_Colors()
{
yield return new object[]
{
Color.FromName("Chocolate"),
Color.FromArgb(144, 255, 78, 240),
};
yield return new object[]
{
Review

these are both the same, is it normal?

these are both the same, is it normal?
Color.FromName("Chocolate"),
Color.FromArgb(144, 255, 78, 240),
};
}
[Theory]
[MemberData(nameof(Data_Colors))]
public void ColorFaceValueTest(Color clrA,Color clrB)
{
//Arrage
ColorFace face1 = new(clrA);
ColorFace face2 = new(clrB);
//Act
Color expected1 = clrA;
Color actual1 = face1.Value;
Color expected2 = clrB;
Color actual2 = face2.Value;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
[Theory]
[MemberData(nameof(Data_Colors))]
public void ColorFaceValueToStringTest(Color clrA, Color clrB)
{
//Arrage
ColorFace face1 = new(clrA);
ColorFace face2 = new(clrB);
//Act
string expected1 = clrA.ToString();
string actual1 = face1.StringValue;
string expected2 = clrB.ToString();
string actual2 = face2.StringValue;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
}
}

@ -0,0 +1,74 @@
using Model.Dice.Faces;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace Tests.Model_UTs.Dice.Faces
{
public class FaceImageTest
{
public static IEnumerable<object[]> Data_Colors()
{
yield return new object[]
{
new Uri("http://www.contoso.com/"),
new Uri("https://www.pedagojeux.fr/wp-content/uploads/2019/11/1280x720_LoL.jpg"),
};
yield return new object[]
{
new Uri("https://www.lacremedugaming.fr/wp-content/uploads/creme-gaming/2022/02/media-13411.jpg"),
new Uri("https://i1.moyens.net/io/images/2022/01/1642321015_Mises-a-jour-de-VALORANT-en-melee-a-venir-dans.jpg"),
};
}
[Theory]
[MemberData(nameof(Data_Colors))]
public void ImageFaceValueTest(Uri uriA, Uri uriB)
{
//Arrage
ImageFace face1 = new(uriA);
ImageFace face2 = new(uriB);
//Act
Uri expected1 = uriA;
Uri actual1 = face1.Value;
Uri expected2 = uriB;
Uri actual2 = face2.Value;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
[Theory]
[MemberData(nameof(Data_Colors))]
public void ImageFaceValueToStringTest(Uri uriA, Uri uriB)
{
//Arrage
ImageFace face1 = new(uriA);
ImageFace face2 = new(uriB);
//Act
string expected1 = uriA.ToString();
string actual1 = face1.StringValue;
string expected2 = uriB.ToString();
string actual2 = face2.StringValue;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
}
}

@ -0,0 +1,59 @@
using Model.Dice.Faces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace Tests.Model_UTs.Dice.Faces
{
public class FaceNumber
{
[Fact]
public void NumberFaceValueTest()
{
//Arrage
NumberFace face1 = new NumberFace(3);
NumberFace face2 = new NumberFace(5);
//Act
int expected1 = 3;
int actual1 = face1.Value;
int expected2 = 5;
int actual2 = face2.Value;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
[Fact]
public void NumberFaceValueToStringTest()
{
//Arrage
NumberFace face1 = new(3);
NumberFace face2 = new(5);
//Act
string expected1 = 3.ToString();
string actual1 = face1.StringValue;
string expected2 = 5.ToString();
string actual2 = face2.StringValue;
//Assert
Assert.Equal(expected1, actual1);
Assert.Equal(expected2, actual2);
}
}
}

@ -0,0 +1,57 @@
using Model.Dice.Faces;
using Model.Dice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using System.Drawing;
using Model.Dice.Faces;
Review

please remove this 'using' (double using, code smell)

please remove this 'using' (double using, code smell)
namespace Tests.Model_UTs.Dice
{
public class ImageDieTest
{
public static IEnumerable<object[]> Data_Uri()
{
yield return new object[]
{
new ImageFace(new Uri("https://nothing1/")),
new ImageFace(new Uri("https://nothing2/")),
new ImageFace(new Uri("https://nothing3/")),
new ImageFace(new Uri("https://nothing4/")),
new ImageFace(new Uri("https://nothing5/")),
};
}
[Theory]
[MemberData(nameof(Data_Uri))]
public void RndmFaceTest(ImageFace f1, ImageFace f2, ImageFace f3, ImageFace f4, ImageFace f5)
{
//Arrange
List<ImageFace> listFaces = new() {
f1,f2,f3,f4,f5
};
ImageDie die = new(
listFaces[1],
listFaces[2],
listFaces[3],
listFaces[4]
);
//Act
ImageFace actual = (ImageFace)die.GetRandomFace();
//Assert
Assert.Contains(listFaces, face => face == actual);
}
}
}

@ -0,0 +1,45 @@
using Model.Dice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Model.Dice.Faces;
using System.Diagnostics;
namespace Tests.Model_UTs.Dice
{
public class NumberDieTest
{
[Fact]
public void RndmFaceTest()
{
//Arrange
List<NumberFace> listFaces = new() {
new NumberFace(1),
new NumberFace(2),
new NumberFace(3),
new NumberFace(4),
new NumberFace(5),
};
NumberDie die = new(
listFaces[1],
listFaces[2],
listFaces[3],
listFaces[4]
);
//Act
NumberFace actual = (NumberFace)die.GetRandomFace();
//Assert
Assert.Contains(listFaces, face =>face==actual);
}
}
}
Loading…
Cancel
Save