From 2429329049e22d697060293df91f24623e10c9e9 Mon Sep 17 00:00:00 2001 From: "mohammad_zafir.jeeawody" Date: Mon, 10 Oct 2022 03:11:20 +0200 Subject: [PATCH] testDiceGroupManager --- .../Data_UTs/Dice/DiceGroupManagerTest.cs | 89 +++++++++++++++++++ .../Model_UTs/Dice/DiceGroupDbManagerTest.cs | 12 --- Sources/Tests/Tests.csproj | 1 + 3 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 Sources/Tests/Data_UTs/Dice/DiceGroupManagerTest.cs delete mode 100644 Sources/Tests/Model_UTs/Dice/DiceGroupDbManagerTest.cs diff --git a/Sources/Tests/Data_UTs/Dice/DiceGroupManagerTest.cs b/Sources/Tests/Data_UTs/Dice/DiceGroupManagerTest.cs new file mode 100644 index 0000000..bde0ccd --- /dev/null +++ b/Sources/Tests/Data_UTs/Dice/DiceGroupManagerTest.cs @@ -0,0 +1,89 @@ +using Data.EF; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Model.Dice; +using Model.Dice.Faces; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace Tests.Data_UTs.Dice +{ + public class DiceGroupManagerTest + { + [Fact] + public void TestConstructorReturnsEmptyEnumerable() + { + // Arrange + DiceGroupManager diceGroupManager = new(); + Dictionary> expected; + Dictionary> actual; + + // Act + expected = new Dictionary>(); + actual = (Dictionary>)diceGroupManager.GetAll(); + + // Assert + Xunit.Assert.Equal(expected, actual); + + } + + [Fact] + public void TestAddIfDieGroupThenDoAddAndDieGroup() + { + List faces = new (); + faces.Add(new NumberFace(2)); + faces.Add(new NumberFace(3)); + faces.Add(new NumberFace(7)); + + NumberFace[] facesArr = faces.ToArray(); + faces.Clear(); + + + /* facesArr[0] = new NumberFace(2); + facesArr[1] = new NumberFace(3); + facesArr[2] = new NumberFace(7);*/ + faces.Add(new NumberFace(3)); + faces.Add(new NumberFace(5)); + faces.Add(new NumberFace(6)); + + NumberFace[] facesArr1 = faces.ToArray(); + + /*facesArr1[0] = new NumberFace(3); + facesArr1[1] = new NumberFace(5); + facesArr1[2] = new NumberFace(6); +*/ + Collection collectDie = new(); + + + + Dictionary> diceGroupsActuel = new(); + + NumberDie die = new NumberDie(facesArr[0], facesArr[1..]); + NumberDie die2 = new NumberDie(facesArr1[0], facesArr1[1..]); + + collectDie.Add(die); + collectDie.Add(die2); + + + Collection ExpectedDie = new(); + ExpectedDie.Add(new NumberDie(new NumberFace(2), new NumberFace(3), new NumberFace(7))); + ExpectedDie.Add(new NumberDie(new NumberFace(3), new NumberFace(5), new NumberFace(6))); + + + Dictionary> diceGroupExpected = new();//to ask direct initialization why cannot + diceGroupExpected.Add("Monopoly", ExpectedDie); + diceGroupsActuel.Add("Monopoly", collectDie); + + CollectionAssert.AreEqual(collectDie, ExpectedDie); + + } + + + } +} diff --git a/Sources/Tests/Model_UTs/Dice/DiceGroupDbManagerTest.cs b/Sources/Tests/Model_UTs/Dice/DiceGroupDbManagerTest.cs deleted file mode 100644 index e712993..0000000 --- a/Sources/Tests/Model_UTs/Dice/DiceGroupDbManagerTest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tests.Model_UTs.Dice -{ - public class DiceGroupDbManagerTest - { - } -} diff --git a/Sources/Tests/Tests.csproj b/Sources/Tests/Tests.csproj index 2075e70..e2e5053 100644 --- a/Sources/Tests/Tests.csproj +++ b/Sources/Tests/Tests.csproj @@ -8,6 +8,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive