public async Task RegisterEventReturnsSuccess() { var sut = new EventApiController(Mock.Of <IMediator>()); var result = await sut.RegisterEvent(new EventSignupViewModel()); Assert.True(result.ToString().Contains("success")); }
public async Task RegisterEventReturnsHttpBadRequetWhenSignupModelIsNull() { var sut = new EventApiController(null); var result = await sut.RegisterEvent(null); Assert.IsType <BadRequestResult>(result); }
public async Task RegisterEventSendsEventSignupCommandAsyncWithCorrectData() { var model = new EventSignupViewModel(); var mediator = new Mock <IMediator>(); var sut = new EventApiController(mediator.Object); await sut.RegisterEvent(model); mediator.Verify(x => x.SendAsync(It.Is <EventSignupCommand>(command => command.EventSignup.Equals(model)))); }
public async Task RegisterEventReturnsCorrectJsonWhenModelStateIsNotValid() { const string modelStateErrorMessage = "modelStateErrorMessage"; var sut = new EventApiController(null); sut.AddModelStateErrorWithErrorMessage(modelStateErrorMessage); var jsonResult = (JsonResult)await sut.RegisterEvent(new EventSignupViewModel()); var result = jsonResult.GetValueForProperty <List <string> >("errors"); Assert.IsType <JsonResult>(jsonResult); Assert.IsType <List <string> >(result); Assert.Equal(result.First(), modelStateErrorMessage); }