public void AddEventValidModelAndFailedDatabaseReturnsBadRequest() { //Setup var mockEventsRepo = new Mock <IEventRepo>(); var mockEventResultsRepo = new Mock <IEventResultsRepo>(); var mockUserRepo = new Mock <IUserRepo>(); var addEvent = new EventAddModel() { EventAge = "21", EventCode = "01", EventGender = "M", MeetId = 1, Round = "F" }; mockEventsRepo.Setup(MER => MER.AddEvent(addEvent)).Returns(false); var sut = new EventsController(mockEventsRepo.Object, mockEventResultsRepo.Object, mockUserRepo.Object); //Action var res = sut.AddEvent(addEvent); //Assert res.Should().BeOfType <BadRequestErrorMessageResult>(); res.As <BadRequestErrorMessageResult>().Message.Should().Be("Failed to add to database"); }
public void AddEventValidModelAndDatabaseReturnsOk() { //Setup var mockEventsRepo = new Mock <IEventRepo>(); var mockEventResultsRepo = new Mock <IEventResultsRepo>(); var mockUserRepo = new Mock <IUserRepo>(); var addEvent = new EventAddModel() { EventAge = "21", EventCode = "01", EventGender = "M", MeetId = 1, Round = "F" }; mockEventsRepo.Setup(MER => MER.AddEvent(addEvent)).Returns(true); var sut = new EventsController(mockEventsRepo.Object, mockEventResultsRepo.Object, mockUserRepo.Object); //Action var res = sut.AddEvent(addEvent); //Assert res.Should().BeOfType <OkResult>(); }