public void RemoveConference_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new ConferenceRepository(dbContext); var conference = new Conference(); A.CallTo(() => dbContext.Conferences.Remove(A <Conference> .Ignored)).Returns(conference); // Act var result = repository.RemoveEntity(conference); // Assert A.CallTo(() => dbContext.Conferences.Remove(conference)).MustHaveHappenedOnceExactly(); Assert.AreSame(conference, result); }
public void RemoveConference_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new ConferenceRepository(dbContext); var conference = new Conference(); A.CallTo(() => dbContext.Conferences.Remove(A <Conference> .Ignored)).Throws <Exception>(); // Act Conference result = null; Assert.Throws <Exception>(() => result = repository.RemoveEntity(conference)); // Assert Assert.IsNull(result); }