Exemplo n.º 1
0
        [Test] public void RemoveDuplicateTest()
        {
            var l = new RandomList <int> {
                1, 2, 2, 3, 4
            };

            Assert.AreEqual(true, l.Remove(2));
            Assert.AreEqual(F.list(1, 4, 2, 3), l);
            Assert.AreEqual(4, l.Count);
            Assert.AreEqual(true, l.Remove(2));
            Assert.AreEqual(F.list(1, 4, 3), l);
            Assert.AreEqual(3, l.Count);
        }
Exemplo n.º 2
0
        [Test] public void RemoveNonExistingTest()
        {
            var l = new RandomList <int> {
                1, 2, 3, 4
            };

            Assert.AreEqual(false, l.Remove(5));
            Assert.AreEqual(F.list(1, 2, 3, 4), l);
            Assert.AreEqual(4, l.Count);
        }
Exemplo n.º 3
0
        [Test] public void RemoveFromEndTest()
        {
            var l = new RandomList <int> {
                1, 2, 3, 4
            };

            Assert.AreEqual(true, l.Remove(4));
            Assert.AreEqual(F.list(1, 2, 3), l);
            Assert.AreEqual(3, l.Count);
        }
Exemplo n.º 4
0
    public string RandomString(RandomList rndList)
    {
        Random rnd = new Random();

        int    randomIndex = rnd.Next(0, rndList.Count);
        string str         = rndList[randomIndex];

        rndList.Remove(str);
        return(str);
    }
Exemplo n.º 5
0
        public Coroutine after(Duration duration, Action act, string name)
        {
            TestTimeContextCoroutine cr = null;
            // ReSharper disable once PossibleNullReferenceException
            var entry = F.t(timePassed + duration, (Action)(() => cr.timeHit()), name);

            cr           = new TestTimeContextCoroutine(() => actions.Remove(entry));
            cr.onFinish += act;
            actions.Add(entry);
            return(cr);
        }
Exemplo n.º 6
0
        public void Removing_NonExistentItem()
        {
            // Arrange
            var randList = new RandomList <int> {
                1, 2, 3
            };

            // Act
            bool resutl = randList.Remove(5);

            // Assert
            Assert.False(resutl);
        }
Exemplo n.º 7
0
    public List <T> GetRandomItems(int count)
    {
        List <T> result = new List <T>();
        var      tl     = new RandomList <T>(this);

        for (int i = 0; i < count; i++)
        {
            if (tl.Count <= 0)
            {
                break;
            }
            var t = tl.GetRandomItem();
            result.Add(t);
            tl.Remove(t);
            tl.TotalValue = 0;
        }
        return(result);
    }
Exemplo n.º 8
0
        public void RemovingItems(int itemsCount)
        {
            // Arrange
            var randList = new RandomList <int>();

            for (int i = 0; i < itemsCount; i++)
            {
                randList.Add(i);
            }

            // Act
            for (int i = 0; i < itemsCount; i++)
            {
                randList.Remove(i);
            }

            // Assert
            Assert.True(0 == randList.Count);
        }