Пример #1
0
        public void Remove()
        {
            var parent = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1), new Person("Child2", 2), new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent);
            _source.Remove(parent);
            _results.Data.Count.Should().Be(0, "Should be 4 in the cache");
        }
Пример #2
0
        public void Adds()
        {
            var parent = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child2", 2),
                new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent);
            _results.Data.Count.Should().Be(3, "Should be 4 in the cache");

            _results.Data.Lookup("Child1").HasValue.Should().BeTrue();
            _results.Data.Lookup("Child2").HasValue.Should().BeTrue();
            _results.Data.Lookup("Child3").HasValue.Should().BeTrue();
        }
Пример #3
0
        public void Adds()
        {
            var parent = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child2", 2),
                new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent);
            Assert.AreEqual(3, _results.Data.Count, "Should be 4 in the cache");

            Assert.IsTrue(_results.Data.Lookup("Child1").HasValue, "Child 1 should be in the cache");
            Assert.IsTrue(_results.Data.Lookup("Child2").HasValue, "Child 2 should be in the cache");
            Assert.IsTrue(_results.Data.Lookup("Child3").HasValue, "Child 3 should be in the cache");
        }
Пример #4
0
        public void UpdateWithLessChildren()
        {
            var parent1 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1), new Person("Child2", 2), new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent1);

            var parent2 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1), new Person("Child3", 3),
            });

            _source.AddOrUpdate(parent2);
            _results.Data.Count.Should().Be(2, "Should be 2 in the cache");
            _results.Data.Lookup("Child1").HasValue.Should().BeTrue();
            _results.Data.Lookup("Child3").HasValue.Should().BeTrue();
        }
Пример #5
0
        public void RemovewithIncompleteChildren()
        {
            var parent1 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child2", 2),
                new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent1);

            var parent2 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child3", 3)
            });

            _source.Remove(parent2);
            Assert.AreEqual(0, _results.Data.Count, "Should be 0 in the cache");
        }
Пример #6
0
        public void UpdateWithLessChildren()
        {
            var parent1 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child2", 2),
                new Person("Child3", 3)
            });

            _source.AddOrUpdate(parent1);

            var parent2 = new PersonWithChildren("parent", 50, new Person[]
            {
                new Person("Child1", 1),
                new Person("Child3", 3),
            });

            _source.AddOrUpdate(parent2);
            Assert.AreEqual(2, _results.Data.Count, "Should be 2 in the cache");
            Assert.IsTrue(_results.Data.Lookup("Child1").HasValue, "Child 1 should be in the cache");
            Assert.IsTrue(_results.Data.Lookup("Child3").HasValue, "Child 3 should be in the cache");
        }