public void RegisteringACustomPersistenceService() { BuilderSetup.SetPersistenceService(new MockCustomPersistenceService()); Builder <Product> .CreateNew().Persist(); Assert.That(MockCustomPersistenceService.ProductPersisted, Is.True); }
public void SetUp() { mocks = new MockRepository(); persistenceService = mocks.DynamicMock <IPersistenceService>(); repository = mocks.DynamicMock <IMyClassRepository>(); builderSetup = new BuilderSetup(); builderSetup.SetPersistenceService(this.persistenceService); }
public void SetUp() { mocks = new MockRepository(); persistenceService = mocks.DynamicMock<IPersistenceService>(); repository = mocks.DynamicMock<IMyClassRepository>(); builderSetup = new BuilderSetup(); builderSetup.SetPersistenceService(this.persistenceService); }
public void ShouldBeAbleToPersistUsingListBuilder() { using (mocks.Record()) { listBuilderImpl.Expect(x => x.Build()).Return(theList); persistenceService.Expect(x => x.Create(theList)); } BuilderSetup.SetPersistenceService(persistenceService); using (mocks.Playback()) { PersistenceExtensions.Persist(listBuilderImpl); } }
public void ShouldBeAbleToPersistFromADeclaration() { using (mocks.Record()) { listBuilderImpl.Expect(x => x.Build()).Return(theList); persistenceService.Expect(x => x.Create(theList)); ((IDeclaration <MyClass>)operable).Expect(x => x.ListBuilderImpl).Return(listBuilderImpl); } BuilderSetup.SetPersistenceService(persistenceService); using (mocks.Playback()) { PersistenceExtensions.Persist(operable); } }
public void ShouldBeAbleToPersistUsingSingleObjectBuilder() { var obj = new MyClass(); using (mocks.Record()) { singleObjectBuilder.Expect(x => x.Build()).Return(obj); persistenceService.Expect(x => x.Create(obj)); } BuilderSetup.SetPersistenceService(persistenceService); using (mocks.Playback()) { PersistenceExtensions.Persist(singleObjectBuilder); } }
public void ShouldBeAbleToPersistFromADeclaration() { var builderSetup = new BuilderSetup(); using (mocks.Record()) { listBuilderImpl.Stub(x => x.BuilderSetup).Return(builderSetup); listBuilderImpl.Expect(x => x.Build()).Return(theList); listBuilderImpl.Stub(x => x.BuilderSetup).Return(builderSetup); persistenceService.Expect(x => x.Create(theList)); ((IDeclaration<MyClass>) operable).Expect(x => x.ListBuilderImpl).Return(listBuilderImpl); } using (mocks.Playback()) { builderSetup.SetPersistenceService(persistenceService); PersistenceExtensions.Persist(operable); } }
public void ShouldBeAbleToUsePersistHierarchy() { var hierarchySpec = mocks.Stub <IHierarchySpec <MyClass> >(); var persistenceService = mocks.DynamicMock <IPersistenceService>(); BuilderSetup.SetPersistenceService(persistenceService); using (mocks.Record()) { listBuilderImpl.Expect(x => x.Build()).Return(new List <MyClass>()).Repeat.Any(); persistenceService.Expect(x => x.Create(Arg <MyClass> .Is.TypeOf)).Repeat.Any(); persistenceService.Expect(x => x.Update(Arg <IList <MyClass> > .Is.TypeOf)).Repeat.Once(); } using (mocks.Playback()) { ListBuilderExtensions.PersistHierarchy(listBuilderImpl, hierarchySpec); } }
public void ShouldBeAbleToUsePersistHierarchy() { var buildersetup = new BuilderSetup(); var hierarchySpec = mocks.Stub<IHierarchySpec<MyClass>>(); var persistenceService = mocks.DynamicMock<IPersistenceService>(); using (mocks.Record()) { listBuilderImpl.Stub(x => x.BuilderSetup).Return(buildersetup); listBuilderImpl.Expect(x => x.Build()).Return(new List<MyClass>()).Repeat.Any(); persistenceService.Expect(x => x.Create(Arg<MyClass>.Is.TypeOf)).Repeat.Any(); persistenceService.Expect(x => x.Update(Arg<IList<MyClass>>.Is.TypeOf)).Repeat.Once(); } using (mocks.Playback()) { buildersetup.SetPersistenceService(persistenceService); ListBuilderExtensions.PersistHierarchy(listBuilderImpl, hierarchySpec); } }
public void ShouldBeAbleToPersistUsingListBuilder() { var builderSetup = new BuilderSetup(); using (mocks.Record()) { listBuilderImpl.Stub(x => x.BuilderSetup).Return(builderSetup); listBuilderImpl.Expect(x => x.Build()).Return(theList); persistenceService.Expect(x => x.Create(theList)); } using (mocks.Playback()) { builderSetup.SetPersistenceService(persistenceService); PersistenceExtensions.Persist(listBuilderImpl); } }
public void ShouldBeAbleToPersistUsingSingleObjectBuilder() { var builderSetup = new BuilderSetup(); var obj = new MyClass(); using (mocks.Record()) { singleObjectBuilder.Stub(x => x.BuilderSetup).Return(builderSetup); singleObjectBuilder.Expect(x => x.Build()).Return(obj); persistenceService.Expect(x => x.Create(obj)); } using (mocks.Playback()) { builderSetup.SetPersistenceService(persistenceService); PersistenceExtensions.Persist(singleObjectBuilder); } }
public void Configuration_1() { BuilderSetup.SetPersistenceService(new MyCustomPersistenceService()); }