Exemplo n.º 1
0
        public void ShouldBeAbleToPersistAnObject_Create()
        {
            var obj = new MyClass();

            PersistenceService persistenceService = new PersistenceService();

            persistenceService.SetPersistenceCreateMethod <MyClass>(x => repository.Save(x));

            using (mocks.Record())
            {
                repository.Expect(x => x.Save(obj));
            }

            using (mocks.Playback())
            {
                persistenceService.Create(obj);
            }
        }
Exemplo n.º 2
0
        public void ShouldReplaceExistingCreatePersister()
        {
            var obj = new MyClass();

            PersistenceService persistenceService = new PersistenceService();

            persistenceService.SetPersistenceCreateMethod <MyClass>(x => repository.Save(x));
            persistenceService.SetPersistenceCreateMethod <MyClass>(x => repository2.Save(x));

            using (mocks.Record())
            {
                repository2.Expect(x => x.Save(obj));
            }

            using (mocks.Playback())
            {
                persistenceService.Create(obj);
            }
        }