public async Task RegisterActivityReturnsHttpStatusResultOfOk() { var sut = new ActivityApiController(Mock.Of<IMediator>()); var result = (HttpStatusCodeResult)await sut.RegisterActivity(new ActivitySignupViewModel()); Assert.IsType<HttpStatusCodeResult>(result); Assert.Equal(result.StatusCode, (int)HttpStatusCode.OK); }
public async Task RegisterActivitySendsActivitySignupCommandAsyncWithCorrectData() { var model = new ActivitySignupViewModel(); var mediator = new Mock<IMediator>(); var sut = new ActivityApiController(mediator.Object); await sut.RegisterActivity(model); mediator.Verify(x => x.SendAsync(It.Is<ActivitySignupCommand>(command => command.ActivitySignup.Equals(model)))); }
public async Task RegisterActivityReturnsHttpBadRequetWhenSignupModelIsNull() { var sut = new ActivityApiController(null); var result = await sut.RegisterActivity(null); Assert.IsType<BadRequestResult>(result); }
public async Task RegisterActivityReturnsCorrectJsonWhenModelStateIsNotValid() { const string modelStateErrorMessage = "modelStateErrorMessage"; var sut = new ActivityApiController(null); sut.AddModelStateError(modelStateErrorMessage); var jsonResult = (JsonResult)await sut.RegisterActivity(new ActivitySignupViewModel()); var result = jsonResult.GetValueForProperty<List<string>>("errors"); Assert.IsType<JsonResult>(jsonResult); Assert.IsType<List<string>>(result); Assert.Equal(result.First(), modelStateErrorMessage); }
public async Task RegisterActivityReturnsSuccess() { var sut = new ActivityApiController(Mock.Of<IMediator>()); var result = (object)await sut.RegisterActivity(new ActivitySignupViewModel()); Assert.True(result.ToString().Contains("success")); }