Beispiel #1
0
        public void RoundRobin_ShouldReturnTheOnlyEntryMultipleTimes()
        {
            const string theOnlyOne = "theOnlyOne";

            var sut = new RoundRobin <string>();

            sut.Add(theOnlyOne);

            Assert.Equal(theOnlyOne, sut.Get());
            Assert.Equal(theOnlyOne, sut.Get());
            Assert.Equal(theOnlyOne, sut.Get());
            Assert.Equal(theOnlyOne, sut.Get());
        }
Beispiel #2
0
        public void RoundRobin_ShouldReturnEntriesInOrder()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            Assert.Equal(firstEntry, sut.Get());
            Assert.Equal(secondEntry, sut.Get());
            Assert.Equal(thirdEntry, sut.Get());
        }
Beispiel #3
0
        public void RoundRobin_ShouldReturnEntriesAddedAfterInitialisation()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry
            };

            Assert.Equal(firstEntry, sut.Get());
            Assert.Equal(secondEntry, sut.Get());
            sut.Add(thirdEntry);
            Assert.Equal(thirdEntry, sut.Get());
        }
Beispiel #4
0
        public void RoundRobin_ShouldReturnNextEntryWhenLastReturnedRemovedByUpdate()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            Assert.Equal(firstEntry, sut.Get());
            Assert.Equal(secondEntry, sut.Get());
            sut.Update(new [] { firstEntry, thirdEntry });
            Assert.Equal(thirdEntry, sut.Get());
        }
Beispiel #5
0
        public void RoundRobin_ShouldReturnNextEntryWhenAnyPreviousRemoved()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            Assert.Equal(firstEntry, sut.Get());
            Assert.Equal(secondEntry, sut.Get());
            sut.Remove(firstEntry);
            Assert.Equal(thirdEntry, sut.Get());
        }
Beispiel #6
0
        public void RoundRobinOfReferenceType_ShouldReturnNull_WhenEmpty()
        {
            var sut    = new RoundRobin <string>();
            var result = sut.Get();

            Assert.Null(result);
        }
Beispiel #7
0
        public void RoundRobinOfValueType_ShouldReturnDefault_WhenEmpty()
        {
            var sut    = new RoundRobin <int>();
            var result = sut.Get();

            Assert.Equal(0, result);
        }
Beispiel #8
0
        public void RoundRobin_ShouldReturnEntriesWhenUpdateChangesNothing()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            Assert.Equal(firstEntry, sut.Get());
            Assert.Equal(secondEntry, sut.Get());
            sut.Update(new[] {
                firstEntry, secondEntry, thirdEntry
            });
            Assert.Equal(thirdEntry, sut.Get());
        }
Beispiel #9
0
        public void RoundRobin_ShouldReturnTheOnlyEntry()
        {
            const string theOnlyOne = "theOnlyOne";

            var sut = new RoundRobin <string>();

            sut.Add(theOnlyOne);
            var result = sut.Get();

            Assert.Equal(theOnlyOne, result);
        }
Beispiel #10
0
        public void RoundRobin_ShouldReturnNextWhenNotExistingEntryRemoved()
        {
            const string firstEntry       = "entry1";
            const string secondEntry      = "entry2";
            const string notExistingEntry = "fakeEntry";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry
            };

            sut.Remove(notExistingEntry);
            Assert.Equal(firstEntry, sut.Get());
        }
Beispiel #11
0
        public void RoundRobin_ShouldReturnDefaultWhenCleared()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            sut.Clear();
            Assert.Null(sut.Get());
        }
Beispiel #12
0
        public void RoundRobin_ShouldReturnDefaultWhenAllEntriesRemoved()
        {
            const string firstEntry  = "entry1";
            const string secondEntry = "entry2";
            const string thirdEntry  = "entry3";

            var sut = new RoundRobin <string> {
                firstEntry, secondEntry, thirdEntry
            };

            sut.Remove(firstEntry);
            sut.Remove(secondEntry);
            sut.Remove(thirdEntry);
            Assert.Null(sut.Get());
        }