public void FrontEndServiceShouldStorePersonCreatedEvents() { // Arrance var dbset = new DummyDbSet <Person>(); var context = new DummyFrontEndContext(dbset); var service = new FrontEndService(context); // Act service.Execute(new PersonCreated { }); // Assert Assert.True(dbset.AddIsCalled); Assert.True(context.SaveChangedIsCalled); }
public void FrontEndServiceShouldStorePersonCreatedEventsWithMoq() { // Arrange var dbset = Substitute.For <DbSet <Person> >(); var context = Substitute.For <IFrontEndContext>(); context.People.Returns(dbset); var service = new FrontEndService(context); // Act service.Execute(new PersonCreated { }); // Assert dbset.Received(1).Add(Arg.Any <Person>()); context.Received(1).SaveChanges(); }