Exemplo n.º 1
0
        public void TestRemove()
        {
            Object expected;
            Object current;

            //Given
            var tog1 = new Toggle("feature-alpha");
            var repo = new ToggleRepositoryInMemory();

            //When
            repo.put(tog1);

            //Then
            expected = 1;
            current  = repo.cardinality();
            Assert.Equal(expected, current);

            //When
            repo.remove(tog1);

            //Then
            expected = 0;
            current  = repo.cardinality();
            Assert.Equal(expected, current);

            //When
            repo.put(tog1);

            //Then
            expected = tog1;
            current  = repo.remove(tog1);
            Assert.Equal(expected, current);
        }
Exemplo n.º 2
0
        public void TestPutAddingMoreThanOnceAndCardinality()
        {
            //Given
            var repo = new ToggleRepositoryInMemory();
            var t_a  = new Toggle("alpha");

            //When
            repo.put(t_a);
            repo.put(t_a);

            //Then
            Assert.Null(repo.put(t_a));
            Assert.True(1 == repo.cardinality()); // remains 1
        }