public void RemoveParent() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); _source.Add(mother); _source.Remove(mother); _results.Data.Count.Should().Be(0); }
public void ChildrenAreRemovedWhenParentIsRemoved() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.AddOrUpdate(mother); _source.Remove(mother); Assert.AreEqual(0, _results.Data.Count, "Should be 4 in the cache"); }
public void ChildrenAreRemovedWhenParentIsRemoved() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.Add(mother); _source.Remove(mother); Assert.AreEqual(0, _results.Data.Count, "Should be 4 in the cache"); }
public void Add() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] {frientofchild1}); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] {child1, child2, child3}); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.Add(mother); _results.Data.Count.Should().Be(4); _results.Data.Items.ShouldAllBeEquivalentTo(new[] { child1, child2, child3, frientofchild1 }); }
public void RecursiveChildrenCanBeAdded() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] {frientofchild1}); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] {child1, child2, child3}); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.AddOrUpdate(mother); Assert.AreEqual(4,_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"); Assert.IsTrue(_results.Data.Lookup("Friend1").HasValue, "Friend 1 should be in the cache"); }
public void Move() { //Move should have no effect var child4 = new PersonWithRelations("Child4", 1); var child5 = new PersonWithRelations("Child5", 2); var anotherRelative1 = new PersonWithRelations("Another1", 2, new[] { child4, child5 }); var child6 = new PersonWithRelations("Child6", 1); var child7 = new PersonWithRelations("Child7", 2); var anotherRelative2 = new PersonWithRelations("Another2", 2, new[] { child6, child7 }); _source.AddRange(new[] { anotherRelative1, anotherRelative2 }); _results.Messages.Count.Should().Be(1); _source.Move(1, 0); _results.Messages.Count.Should().Be(1); }
public void RecursiveChildrenCanBeAdded() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.Add(mother); Assert.AreEqual(4, _results.Data.Count, "Should be 4 in the cache"); Assert.IsTrue(_results.Data.Items.FindItemAndIndex(child1).HasValue, "Child 1 should be in the cache"); Assert.IsTrue(_results.Data.Items.FindItemAndIndex(child2).HasValue, "Child 2 should be in the cache"); Assert.IsTrue(_results.Data.Items.FindItemAndIndex(child3).HasValue, "Child 3 should be in the cache"); Assert.IsTrue(_results.Data.Items.FindItemAndIndex(frientofchild1).HasValue, "Friend 1 should be in the cache"); }
public void RecursiveChildrenCanBeAdded() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.AddOrUpdate(mother); _results.Data.Count.Should().Be(4, "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(); _results.Data.Lookup("Friend1").HasValue.Should().BeTrue(); }
public void Replace() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); _source.Add(mother); var child4 = new PersonWithRelations("Child4", 2); var updatedMother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child4 }); _source.Replace(mother, updatedMother); _results.Data.Count.Should().Be(4); _results.Data.Items.Should().BeEquivalentTo(child1, child2, frientofchild1, child4); }
public void Clear() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); var child4 = new PersonWithRelations("Child4", 1); var child5 = new PersonWithRelations("Child5", 2); var anotherRelative1 = new PersonWithRelations("Another1", 2, new[] { child4, child5 }); var child6 = new PersonWithRelations("Child6", 1); var child7 = new PersonWithRelations("Child7", 2); var anotherRelative2 = new PersonWithRelations("Another2", 2, new[] { child6, child7 }); _source.AddRange(new[] { mother, anotherRelative1, anotherRelative2 }); _source.Clear(); _results.Data.Count.Should().Be(0); }
public void AddRange() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); _source.Add(mother); var child4 = new PersonWithRelations("Child4", 1); var child5 = new PersonWithRelations("Child5", 2); var anotherRelative1 = new PersonWithRelations("Another1", 2, new[] { child4, child5 }); var child6 = new PersonWithRelations("Child6", 1); var child7 = new PersonWithRelations("Child7", 2); var anotherRelative2 = new PersonWithRelations("Another2", 2, new[] { child6, child7 }); _source.AddRange(new[] { anotherRelative1, anotherRelative2 }); _results.Data.Count.Should().Be(8); _results.Data.Items.ShouldAllBeEquivalentTo(new[] { child1, child2, child3, frientofchild1, child4, child5, child6, child7 }); }