public void GetByTypeAndDamageRangeOrderedByDamageThenById_ShouldWorkCorrectly_On_CorrectRange() { //Arrange IArena RA = new RoyaleArena(); Battlecard cd1 = new Battlecard(5, CardType.SPELL, "joro", 1, 5); Battlecard cd2 = new Battlecard(6, CardType.SPELL, "joro", 5.5, 6); Battlecard cd3 = new Battlecard(7, CardType.SPELL, "joro", 5.5, 7); Battlecard cd4 = new Battlecard(12, CardType.SPELL, "joro", 15.6, 10); Battlecard cd5 = new Battlecard(15, CardType.RANGED, "joro", 7.8, 6); List <Battlecard> expected = new List <Battlecard>() { cd4, cd2, cd3, cd1 }; //Act RA.Add(cd1); RA.Add(cd3); RA.Add(cd2); RA.Add(cd4); RA.Add(cd5); //Assert List <Battlecard> actual = RA.GetByTypeAndDamageRangeOrderedByDamageThenById(CardType.SPELL, 0, 20).ToList(); CollectionAssert.AreEqual(expected, actual); }
public void GetByTypeAndDamageRange_ShouldReturnCorrectRange_CorrectlyOrdered() { //Arrange IArena RA = new RoyaleArena(); Battlecard cd1 = new Battlecard(2, CardType.SPELL, "joro", 1, 5); Battlecard cd2 = new Battlecard(1, CardType.SPELL, "joro", 1, 100); Battlecard cd3 = new Battlecard(4, CardType.SPELL, "joro", 15.6, 53); Battlecard cd4 = new Battlecard(3, CardType.SPELL, "joro", 15.6, 100); Battlecard cd5 = new Battlecard(8, CardType.SPELL, "joro", 17.8, 102); List <Battlecard> expected = new List <Battlecard>() { cd5, cd4, cd3, cd2, cd1 }; //Act RA.Add(cd1); RA.Add(cd3); RA.Add(cd2); RA.Add(cd4); RA.Add(cd5); //Assert List <Battlecard> actual = RA.GetByTypeAndDamageRangeOrderedByDamageThenById(CardType.SPELL, 0, 20).ToList(); CollectionAssert.AreEqual(expected, actual); }
public void GetByTypeAndDamageRangeOrderedByDamageThenById_ShouldThrow_On_EmptyRA() { //Arrange IArena RA = new RoyaleArena(); //Act //Assert Assert.Throws <InvalidOperationException>(() => { RA.GetByTypeAndDamageRangeOrderedByDamageThenById(CardType.MELEE, 0, 20).ToList(); }); }
public void GetByTypeAndDamageRangeOrderedByDamageThenById_ShouldThrow_AfterRemovingReceiver() { //Arrange IArena RA = new RoyaleArena(); Battlecard cd1 = new Battlecard(5, CardType.SPELL, "joro", 1, 5); Battlecard cd2 = new Battlecard(6, CardType.RANGED, "joro", 5.5, 5); Battlecard cd3 = new Battlecard(7, CardType.MELEE, "joro", 5.5, 10); //Act RA.Add(cd1); RA.Add(cd3); RA.Add(cd2); RA.RemoveById(5); //Assert Assert.Throws <InvalidOperationException>(() => { RA.GetByTypeAndDamageRangeOrderedByDamageThenById(CardType.SPELL, 0, 20).ToList(); }); }
public void GetByTypeAndDamageRangeOrderedByDamageThenById() { IArena ar = new RoyaleArena(); List <Battlecard> cds = new List <Battlecard>(); Random rand = new Random(); for (int i = 0; i < 100000; i++) { int amount = rand.Next(0, 1000); Battlecard cd = new Battlecard(i, CardType.BUILDING, "sender", amount, 15); ar.Add(cd); if (amount > 200 && amount <= 600) { cds.Add(cd); } } cds = cds.OrderByDescending(x => x.Damage).ThenBy(x => x.Id).ToList(); int count = ar.Count; Assert.AreEqual(100000, count); Stopwatch watch = new Stopwatch(); watch.Start(); IEnumerable <Battlecard> all = ar.GetByTypeAndDamageRangeOrderedByDamageThenById( CardType.BUILDING, 200, 600); int c = 0; foreach (Battlecard cd in all) { Assert.AreSame(cd, cds[c]); c++; } watch.Stop(); long l1 = watch.ElapsedMilliseconds; Assert.Less(l1, 150); Assert.AreEqual(cds.Count, c); }