public void Handle_GivenSuccessfulUseCaseResponse_SetsOKHttpStatusCode() { // arrange var presenter = new ChangePasswordPresenter(); // act presenter.Handle(new UseCaseResponseMessage("", true)); // assert Assert.Equal((int)HttpStatusCode.OK, presenter.ContentResult.StatusCode); }
public void Handle_GivenSuccessfulUseCaseResponse_SetsOKHttpStatusCode() { // arrange var presenter = new ChangePasswordPresenter(_mapper); // act presenter.Handle(new UseCaseResponseMessage("", true)); // assert Assert.NotNull(presenter.Response); Assert.True(presenter.Response.Success); Assert.False(presenter.Response.Errors.Any()); }
public void Handle_GivenSuccessfulUseCaseResponse_SetsId() { // arrange var presenter = new ChangePasswordPresenter(); // act presenter.Handle(new ChangePasswordResponse("1234", true)); // assert dynamic data = JsonConvert.DeserializeObject(presenter.ContentResult.Content); Assert.True(data.success.Value); Assert.Equal("1234", data.id.Value); }
public void Handle_GivenSuccessfulUseCaseResponse_SetsId() { // arrange var presenter = new ChangePasswordPresenter(); // act presenter.Handle(new UseCaseResponseMessage("1234", true)); // assert ChangePasswordResponse response = Serialization.JsonSerializer.DeSerializeObject <ChangePasswordResponse>(presenter.ContentResult.Content); Assert.Equal((int)HttpStatusCode.OK, presenter.ContentResult.StatusCode); Assert.NotNull(response); Assert.Null(response.Errors); Assert.True(response.Success); }
public void Handle_GivenFailedUseCaseResponse_SetsErrors() { // arrange var presenter = new ChangePasswordPresenter(); // act presenter.Handle(new ChangePasswordResponse(new List <Error> { new Error("", "Invalid username/password") })); // assert List <Error> errors = Serialization.JsonSerializer.DeSerializeObject <List <Error> >(presenter.ContentResult.Content); Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode); Assert.NotNull(errors); Assert.NotEmpty(errors); Assert.Equal("Invalid username/password", errors.First().Description); }
public void Handle_GivenFailedUseCaseResponse_SetsErrors() { // arrange var presenter = new ChangePasswordPresenter(_mapper); // act presenter.Handle(new UseCaseResponseMessage(new List <Error> { new Error(HttpStatusCode.BadRequest.ToString(), "Invalid username/password") })); // assert Assert.NotNull(presenter.Response); Assert.NotNull(presenter.Response.Errors); Assert.NotEmpty(presenter.Response.Errors); Assert.False(string.IsNullOrEmpty(presenter.Response.Errors.First().Code)); Assert.False(string.IsNullOrEmpty(presenter.Response.Errors.First().Description)); Assert.Equal(HttpStatusCode.BadRequest.ToString(), presenter.Response.Errors.First().Code); Assert.Equal("Invalid username/password", presenter.Response.Errors.First().Description); }
public void Handle_GivenFailedUseCaseResponse_SetsErrors() { // arrange var presenter = new ChangePasswordPresenter(); // act presenter.Handle(new UseCaseResponseMessage(new List <Error> { new Error(HttpStatusCode.BadRequest.ToString(), "Invalid username/password") })); // assert ChangePasswordResponse response = Serialization.JsonSerializer.DeSerializeObject <ChangePasswordResponse>(presenter.ContentResult.Content); Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode); Assert.NotNull(response); Assert.NotNull(response.Errors); Assert.NotEmpty(response.Errors); Assert.False(string.IsNullOrEmpty(response.Errors.First().Code)); Assert.False(string.IsNullOrEmpty(response.Errors.First().Description)); Assert.Equal(HttpStatusCode.BadRequest.ToString(), response.Errors.First().Code); Assert.Equal("Invalid username/password", response.Errors.First().Description); }