Пример #1
0
    public void GetAllInSwagRange_ShouldReturn_EmptyCollectionOnNonExistingRange()
    {
        //Arrange
        IArena            RA       = new RoyaleArena();
        Battlecard        cd1      = new Battlecard(5, CardType.SPELL, "joro", 2, 1);
        Battlecard        cd2      = new Battlecard(6, CardType.SPELL, "joro", 3, 2);
        Battlecard        cd3      = new Battlecard(7, CardType.SPELL, "joro", 4, 5.5);
        Battlecard        cd4      = new Battlecard(12, CardType.SPELL, "joro", 5, 15.6);
        Battlecard        cd5      = new Battlecard(15, CardType.SPELL, "joro", 6, 7.8);
        List <Battlecard> expected = new List <Battlecard>();

        //Act
        RA.Add(cd1);
        RA.Add(cd3);
        RA.Add(cd2);
        RA.Add(cd4);
        RA.Add(cd5);
        List <Battlecard> actual = RA.GetAllInSwagRange(7.7, 7.75).ToList();

        //Assert
        CollectionAssert.AreEqual(expected, actual);
        RA.RemoveById(12);
        RA.RemoveById(15);
        actual = RA.GetAllInSwagRange(7.8, 16).ToList();
        CollectionAssert.AreEqual(expected, actual);
    }
Пример #2
0
    public void GetByCardType_ShouldReturnCorrectResultAfterRemove()
    {
        //Arrange
        IArena            RA       = new RoyaleArena();
        Battlecard        cd1      = new Battlecard(2, CardType.SPELL, "valq", 2, 14.8);
        Battlecard        cd2      = new Battlecard(1, CardType.SPELL, "valq", 2, 14.8);
        Battlecard        cd3      = new Battlecard(4, CardType.SPELL, "valq", 4, 15.6);
        Battlecard        cd4      = new Battlecard(3, CardType.SPELL, "valq", 3, 15.6);
        Battlecard        cd5      = new Battlecard(8, CardType.RANGED, "valq", 8, 17.8);
        List <Battlecard> expected = new List <Battlecard>()
        {
            cd3, cd2, cd1
        };

        //Act
        RA.Add(cd1);
        RA.Add(cd3);
        RA.Add(cd2);
        RA.Add(cd4);
        RA.Add(cd5);
        RA.RemoveById(8);
        RA.RemoveById(3);
        //Assert
        List <Battlecard> actual = RA
                                   .GetByCardType(CardType.SPELL)
                                   .ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Пример #3
0
    public void GetAllByNameAndSwag_ShouldWorkCorrectly_AfterRemove()
    {
        //Arrange
        IArena            RA       = new RoyaleArena();
        Battlecard        cd1      = new Battlecard(2, CardType.SPELL, "pesho", 5, 14.8);
        Battlecard        cd2      = new Battlecard(1, CardType.SPELL, "pesho", 5, 14.9);
        Battlecard        cd3      = new Battlecard(4, CardType.SPELL, "maru", 5, 15.6);
        Battlecard        cd4      = new Battlecard(3, CardType.SPELL, "pesho", 5, 15.6);
        Battlecard        cd5      = new Battlecard(8, CardType.RANGED, "pesho", 5, 17.8);
        List <Battlecard> expected = new List <Battlecard>()
        {
            cd2, cd3
        };

        //Act
        RA.Add(cd1);
        RA.Add(cd3);
        RA.Add(cd2);
        RA.Add(cd4);
        RA.Add(cd5);
        RA.RemoveById(8);
        RA.RemoveById(3);
        //Assert
        List <Battlecard> actual = RA.GetAllByNameAndSwag().ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Пример #4
0
    public void FindFirstLeastSwag_ShoudlThrowAfterRemove()
    {
        //Arrange
        IArena     RA  = new RoyaleArena();
        Battlecard cd1 = new Battlecard(5, CardType.SPELL, "joro", 5, 1);
        Battlecard cd2 = new Battlecard(6, CardType.SPELL, "joro", 6, 5.5);
        Battlecard cd3 = new Battlecard(7, CardType.SPELL, "joro", 7, 5.5);
        Battlecard cd4 = new Battlecard(12, CardType.SPELL, "joro", 8, 15.6);
        Battlecard cd5 = new Battlecard(15, CardType.RANGED, "joro", 12, 7.8);

        //Act
        RA.Add(cd1);
        RA.Add(cd3);
        RA.Add(cd2);
        RA.Add(cd4);
        RA.Add(cd5);
        RA.RemoveById(5);
        RA.RemoveById(7);
        RA.RemoveById(6);
        RA.RemoveById(12);
        RA.RemoveById(15);
        //Assert
        Assert.Throws <InvalidOperationException>(() =>
        {
            RA.FindFirstLeastSwag(1);
        });
    }
        public void GetByCardType_ShouldReturnCorrectResultAfterRemove()
        {
            //Arrange
            IArena            RA       = new RoyaleArena();
            BattleCard        cd1      = new BattleCard(2, CardType.SPELL, "valq", 2, 14.8);
            BattleCard        cd2      = new BattleCard(1, CardType.SPELL, "valq", 2, 14.8);
            BattleCard        cd3      = new BattleCard(4, CardType.SPELL, "valq", 4, 15.6);
            BattleCard        cd4      = new BattleCard(3, CardType.SPELL, "valq", 3, 15.6);
            BattleCard        cd5      = new BattleCard(8, CardType.RANGED, "valq", 8, 17.8);
            List <BattleCard> expected = new List <BattleCard>()
            {
                cd3, cd2, cd1
            };

            //Act
            RA.Add(cd1);
            RA.Add(cd3);
            RA.Add(cd2);
            RA.Add(cd4);
            RA.Add(cd5);
            RA.RemoveById(8);
            RA.RemoveById(3);

            //Assert
            IEnumerable <BattleCard> battlecards = RA.GetByCardType(CardType.SPELL);
            List <BattleCard>        actual      = new List <BattleCard>();

            foreach (var item in battlecards)
            {
                actual.Add(item);
            }
            CollectionAssert.AreEquivalent(expected, actual);
        }
        public void RA_ShouldReturn_BattlecardsInCorrectOrder_AfterDelete()
        {
            //Arrange
            IArena            RA       = new RoyaleArena();
            BattleCard        cd1      = new BattleCard(5, CardType.SPELL, "joro", 10, 5);
            BattleCard        cd2      = new BattleCard(6, CardType.SPELL, "joro", 11, 5);
            BattleCard        cd3      = new BattleCard(7, CardType.SPELL, "joro", 12, 5);
            List <BattleCard> expected = new List <BattleCard>()
            {
                cd2
            };

            //Act
            RA.Add(cd1);
            RA.Add(cd3);
            RA.Add(cd2);
            RA.RemoveById(5);
            RA.RemoveById(7);
            List <BattleCard> actual = new List <BattleCard>();

            foreach (BattleCard battlecard in RA)
            {
                actual.Add(battlecard);
            }

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Пример #7
0
    public void GetByCardTypeAndMaximumDamage_ShouldOrderAndPickCorrectly()
    {
        //Arrange
        IArena            RA       = new RoyaleArena();
        Battlecard        cd1      = new Battlecard(2, CardType.SPELL, "joro", 1, 6);
        Battlecard        cd2      = new Battlecard(1, CardType.RANGED, "valq", 14.8, 7);
        Battlecard        cd3      = new Battlecard(4, CardType.RANGED, "valq", 15.6, 6);
        Battlecard        cd4      = new Battlecard(3, CardType.RANGED, "valq", 15.6, 12);
        Battlecard        cd5      = new Battlecard(8, CardType.RANGED, "valq", 17.8, 63);
        List <Battlecard> expected = new List <Battlecard>()
        {
            cd3, cd2
        };

        //Act
        RA.Add(cd1);
        RA.Add(cd3);
        RA.Add(cd2);
        RA.Add(cd4);
        RA.Add(cd5);
        RA.RemoveById(8);
        RA.RemoveById(3);
        //Assert
        List <Battlecard> actual = RA.GetByCardTypeAndMaximumDamage(CardType.RANGED, 15.6).ToList();

        CollectionAssert.AreEqual(expected, actual);
    }
Пример #8
0
    public void RemoveById_ShoudlWorkFast()
    {
        IArena            ar   = new RoyaleArena();
        List <Battlecard> cds  = new List <Battlecard>();
        Random            rand = new Random();

        for (int i = 0; i < 40_000; i++)
        {
            int        amount = rand.Next(0, 60000);
            Battlecard cd     = new Battlecard(i, CardType.SPELL,
                                               i.ToString(), i, amount);
            ar.Add(cd);
            cds.Add(cd);
        }

        int count = ar.Count;

        Assert.AreEqual(40000, count);

        Stopwatch watch = new Stopwatch();

        watch.Start();

        foreach (Battlecard cd in cds)
        {
            ar.RemoveById(cd.Id);
        }

        watch.Stop();
        long l1 = watch.ElapsedMilliseconds;

        Assert.Less(l1, 300);
    }
Пример #9
0
    public void Count_Should_RemainCorrect_AfterRemoving()
    {
        //Arrange
        IArena     RA  = new RoyaleArena();
        Battlecard cd1 = new Battlecard(5, CardType.SPELL, "joro", 10, 5);
        Battlecard cd2 = new Battlecard(6, CardType.SPELL, "joro", 10, 5);
        Battlecard cd3 = new Battlecard(7, CardType.SPELL, "joro", 10, 5);

        //Act
        RA.Add(cd1);
        RA.Add(cd2);
        RA.Add(cd3);
        RA.RemoveById(cd1.Id);
        RA.RemoveById(cd3.Id);
        //Assert
        Assert.AreEqual(1, RA.Count);
        Assert.AreNotSame(cd1, RA.GetById(cd2.Id));
    }
Пример #10
0
    public void GetById_On_NonExistingElement_ShouldThrow()
    {
        //Arrange
        IArena     RA  = new RoyaleArena();
        Battlecard cd1 = new Battlecard(5, CardType.SPELL, "joro", 10, 5);
        Battlecard cd2 = new Battlecard(6, CardType.SPELL, "joro", 10, 5);
        Battlecard cd3 = new Battlecard(7, CardType.SPELL, "joro", 10, 5);

        //Act
        RA.Add(cd1);
        RA.Add(cd2);
        RA.Add(cd3);
        RA.RemoveById(5);
        //Assert
        Assert.Throws <InvalidOperationException>(() => RA.GetById(5));
    }
Пример #11
0
    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();
        });
    }