public void SomethingElseUpdateInteractor_UpdateSomethingElseDeleteSomething_PersistsSomethingElseWithSomethingDeleted() { var name = "Fred Bloggs"; var somethingElse1 = Domain.SomethingElse.CreateNamedSomethingElse(name); Mock <ISomethingFactory> mockSomethingFactory = new Mock <ISomethingFactory>(); mockSomethingFactory.Setup(x => x.Create(something.Name)).Returns(something); Mock <ISomethingElseFactory> mockSomethingElseFactory = new Mock <ISomethingElseFactory>(); mockSomethingElseFactory.Setup(x => x.Create(somethingElse1.Name)).Returns(somethingElse1); Mock <ISomethingElsePersistence> mockPersistence = new Mock <ISomethingElsePersistence>(); SomethingElseUpdateInteractor somethingElseInteractor = new SomethingElseUpdateInteractor(mockSomethingFactory.Object, mockSomethingElseFactory.Object, mockPersistence.Object); int else_id = 1; int something_id = 1; somethingElseInteractor.UpdateSomethingElseDeleteSomething(else_id, something_id); mockPersistence.Verify(x => x.UpdateSomethingElseByIdDeleteSomethingById(else_id, something_id)); }
public void SomethingElseUpdateInteractor_UpdateSomethingElseAddSomething_PersistsSomethingElseWithSomethings() { var name = "Fred Bloggs"; var somethingElse1 = Domain.SomethingElse.CreateNamedSomethingElse(name); Mock <ISomethingFactory> mockSomethingFactory = new Mock <ISomethingFactory>(); mockSomethingFactory.Setup(x => x.Create(something.Name)).Returns(something); Mock <ISomethingElseFactory> mockSomethingElseFactory = new Mock <ISomethingElseFactory>(); mockSomethingElseFactory.Setup(x => x.Create(somethingElse1.Name)).Returns(somethingElse1); Mock <ISomethingElsePersistence> mockPersistence = new Mock <ISomethingElsePersistence>(); SomethingElseUpdateInteractor somethingElseInteractor = new SomethingElseUpdateInteractor(mockSomethingFactory.Object, mockSomethingElseFactory.Object, mockPersistence.Object); string othername = "Alice Bloggs"; int id = 1; somethingElseInteractor.UpdateSomethingElseAddSomething(id, othername); mockPersistence.Verify(x => x.UpdateSomethingElseByIdAddSomething(id, something)); }