示例#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);
    }
        public void GetInSwagRange_ShouldReturn_CorrectBattlecards()
        {
            //Arrange
            IArena            RA       = new RoyaleArena();
            BattleCard        cd1      = new BattleCard(5, CardType.SPELL, "dragon", 8, 1);
            BattleCard        cd2      = new BattleCard(6, CardType.SPELL, "raa", 7, 2);
            BattleCard        cd3      = new BattleCard(7, CardType.SPELL, "maga", 6, 5.5);
            BattleCard        cd4      = new BattleCard(12, CardType.SPELL, "shuba", 5, 15.6);
            BattleCard        cd5      = new BattleCard(15, CardType.SPELL, "tanuki", 5, 7.8);
            List <BattleCard> expected = new List <BattleCard>()
            {
                cd5, cd4
            };

            //Act
            RA.Add(cd1);
            RA.Add(cd3);
            RA.Add(cd2);
            RA.Add(cd4);
            RA.Add(cd5);
            IEnumerable <BattleCard> battlecards = RA.GetAllInSwagRange(7, 16);
            List <BattleCard>        actual      = new List <BattleCard>();

            foreach (var b in battlecards)
            {
                actual.Add(b);
            }

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
示例#3
0
    public void GetAllInSwagRange()
    {
        IArena            ar   = new RoyaleArena();
        List <Battlecard> cds  = new List <Battlecard>();
        Random            rand = new Random();

        for (int i = 0; i < 100000; i++)
        {
            Battlecard cd = new Battlecard(i, CardType.SPELL,
                                           "player", 550, i);
            ar.Add(cd);
            cds.Add(cd);
        }
        cds = cds.OrderBy(x => x.Swag).ThenBy(x => x.Id).ToList();
        int count = ar.Count;

        Assert.AreEqual(100000, count);
        Stopwatch watch = new Stopwatch();

        watch.Start();

        for (int i = 0; i < 100; i++)
        {
            IEnumerable <Battlecard> all = ar.GetAllInSwagRange(200, 600);
        }
        watch.Stop();
        long l1 = watch.ElapsedMilliseconds;

        Assert.Less(l1, 150);
    }
示例#4
0
    public void GetAllInSwagRange_ShouldReturnEmptyEnumeration_On_EmptyRA()
    {
        //Arrange
        IArena RA = new RoyaleArena();
        //Act
        List <Battlecard> actual = RA.GetAllInSwagRange(7.7, 7.75).ToList();

        //Assert
        CollectionAssert.AreEqual(new List <Battlecard>(), actual);
    }