public void CustomConversationCanBeSet() { var mock = new MockInstaller(true); var conv = MockRepository.GenerateMock<IConversation>(); conv.Expect(c => c.Commit()); mock.RegisterConversationDouble(conv); var container = mock.GetConfiguredContainer(); container.Resolve<IConversation>().Commit(); conv.VerifyAllExpectations(); }
public void FullTest() { // Arrange var guid = Guid.NewGuid(); var software = new Software { Id = Guid.Empty, Name = "FooBar" }; var mock = new MockInstaller(true); var dao = MockRepository.GenerateMock<IDao<Software>>(); dao.Expect(d => d.Save(software)).WhenCalled(i => { software.Id = guid; }); dao.Expect(d => d.Find(guid)).Return(software); mock.RegisterDaoDouble(dao); var conv = MockRepository.GenerateMock<IConversation>(); conv.Expect(c => c.Execute(Arg<Action>.Is.Anything)).WhenCalled(i => ((Action)i.Arguments[0]).Invoke()); conv.Expect(c => c.Commit()); mock.RegisterConversationDouble(conv); AR.Install(mock); // Act using (var conversation = AR.StartConversation()) { conv.Execute(() => software.Save()); conv.Commit(); Assert.That(AR.Find<Software>(guid), Is.SameAs(software)); } //Assert dao.VerifyAllExpectations(); conv.VerifyAllExpectations(); }