public void ReturnBadRequestResponseShouldLicenseValidationFail() { // Arrange var appId = 1; // Act var resultOne = sutInvalid.GetApp(appId, baseRequest); var messageOne = ((BadRequestObjectResult)resultOne.Result.Result).Value; var statusCodeOne = ((BadRequestObjectResult)resultOne.Result.Result).StatusCode; var resultTwo = sutInvalid.GetApps(baseRequest, true); var messageTwo = ((BadRequestObjectResult)resultTwo.Result.Result).Value; var statusCodeTwo = ((BadRequestObjectResult)resultTwo.Result.Result).StatusCode; var resultThree = sutInvalid.UpdateApp(1, appRequest); var messageThree = ((BadRequestObjectResult)resultThree.Result).Value; var statusCodeThree = ((BadRequestObjectResult)resultThree.Result).StatusCode; var resultFour = sutInvalid.GetAppUsers(1, baseRequest, true); var messageFour = ((BadRequestObjectResult)resultFour.Result.Result).Value; var statusCodeFour = ((BadRequestObjectResult)resultFour.Result.Result).StatusCode; var resultFive = sutInvalid.AddUser(1, 3, baseRequest); var messageFive = ((BadRequestObjectResult)resultFive.Result).Value; var statusCodeFive = ((BadRequestObjectResult)resultFour.Result.Result).StatusCode; var resultSix = sutInvalid.RemoveUser(1, 3, baseRequest); var messageSix = ((BadRequestObjectResult)resultSix.Result).Value; var statusCodeSix = ((BadRequestObjectResult)resultFour.Result.Result).StatusCode; // Assert Assert.That(resultOne.Result, Is.InstanceOf <ActionResult <App> >()); Assert.That(messageOne, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeOne, Is.EqualTo(400)); Assert.That(resultTwo.Result, Is.InstanceOf <ActionResult <IEnumerable <App> > >()); Assert.That(messageTwo, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeTwo, Is.EqualTo(400)); Assert.That(resultThree.Result, Is.InstanceOf <ActionResult>()); Assert.That(messageThree, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeThree, Is.EqualTo(400)); Assert.That(resultFour.Result, Is.InstanceOf <ActionResult <IEnumerable <User> > >()); Assert.That(messageFour, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeFour, Is.EqualTo(400)); Assert.That(resultFive.Result, Is.InstanceOf <ActionResult>()); Assert.That(messageFive, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeFive, Is.EqualTo(400)); Assert.That(resultSix.Result, Is.InstanceOf <ActionResult>()); Assert.That(messageSix, Is.EqualTo("Status Code 400: Invalid Request on this License")); Assert.That(statusCodeSix, Is.EqualTo(400)); }
public void IssueErrorAndMessageShouldSuccessfullyGetAppUsersFail() { // Arrange // Act var result = sutFailure.GetAppUsers( 1, baseRequest, true); var message = ((UsersResult)((NotFoundObjectResult)result.Result.Result).Value).Message; var statusCode = ((NotFoundObjectResult)result.Result.Result).StatusCode; // Assert Assert.That(result.Result, Is.InstanceOf <ActionResult <IEnumerable <User> > >()); Assert.That(message, Is.EqualTo("Status Code 404: Users not Found")); Assert.That(statusCode, Is.EqualTo(404)); }
public void SuccessfullyGetAppUsers() { // Arrange // Act var result = sutSuccess.GetAppUsers( 1, baseRequest, true); var message = ((UsersResult)((OkObjectResult)result.Result.Result).Value).Message; var statusCode = ((OkObjectResult)result.Result.Result).StatusCode; var users = ((UsersResult)((OkObjectResult)result.Result.Result).Value).Users; // Assert Assert.That(result.Result, Is.InstanceOf <ActionResult <IEnumerable <User> > >()); Assert.That(message, Is.EqualTo("Status Code 200: Users Found")); Assert.That(statusCode, Is.EqualTo(200)); Assert.That(users.Count, Is.EqualTo(2)); }