public void CanAddSimpleObject() { var fixture = new InMemorySetFixture(); var obj = new Address(); fixture.InMemorySet.Add(obj); Assert.Equal(1, fixture.InMemorySet.Items.Count); Assert.Equal(obj, fixture.InMemorySet.Items.First()); }
public void InvokesIdGeneratorForAllObjectsInGraph() { var person = new Person(); var address = new Address(); person.Address = address; var fixture = new InMemorySetFixture(); fixture.InMemorySet.Add(person); fixture.IdGenerator.Received(1).Identify(person); fixture.IdGenerator.Received(1).Identify(address); }
public void CanAddNestedObject() { var fixture = new InMemorySetFixture(); var person = new Person(); var address = new Address(); person.Address = address; fixture.InMemorySet.Add(person); Assert.Equal(person, fixture.InMemorySet.Items.Single()); Assert.Equal(address, fixture.Cache.For(typeof (Address)).Items.Single()); }
public void InvokesMaterializationHook() { var address = new Address(); var person = new Person { Address = address }; var fixture = new InMemorySetFixture(); var hook = Substitute.For<IMaterializationHook>(); fixture.MaterializationHooks.Add(hook); fixture.InMemorySet.Add(person); hook.Received(1).Execute(person); hook.Received(1).Execute(address); }