public void ShouldBeAbleToUsePersistHierarchy()
        {
            var buildersetup       = new BuilderSettings();
            var hierarchySpec      = Substitute.For <IHierarchySpec <MyClass> >();
            var persistenceService = Substitute.For <IPersistenceService>();


            listBuilderImpl.BuilderSettings.Returns(buildersetup);
            listBuilderImpl.Build().Returns(new List <MyClass>());
            persistenceService.Create(Arg.Any <MyClass>());
            persistenceService.Update(Arg.Any <IList <MyClass> >());

            buildersetup.SetPersistenceService(persistenceService);
            ListBuilderExtensions.PersistHierarchy(listBuilderImpl, hierarchySpec);
        }
Esempio n. 2
0
        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);
            }
        }