public void ShouldNotAssignIdToInitialisedIdProperty() { var instance = new Person{Id = 9}; instance = (Person)new IdGenerator().Identify(instance); Assert.Equal(9, instance.Id); }
public void AssignsAnIdToIdProperty() { var instance = new Person(); instance = (Person)new IdGenerator().Identify(instance); Assert.Equal(1, instance.Id); }
public void CanMapForeignKey() { var db = new Db().WithForeignKeyInitializer() .MapForeignKey((Person c) => c.Address, c => c._AddressId); var p = new Person {Address = new Address()}; db.Set<Person>().Add(p); Assert.NotNull(p._AddressId); Assert.Null(p.AddressId); }
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); }