public void ConsultaPorIdGameNaoEncontrado() { //arrange PreparaBaseDeDados(); //action var result = _controller.Get(-999999) as NotFoundObjectResult; DtoResponseBase notification = (DtoResponseBase)result.Value; //assert Assert.IsNotNull(result); Assert.AreEqual(404, result.StatusCode); Assert.IsTrue(notification.Notifications[0].ErrorCode == 2); Assert.IsTrue(notification.Success == false); }
public void ConsultaPaginadaNaoEncontrada() { //arrange PreparaBaseDeDados(); //action DtoGameRequest dto = new DtoGameRequest(); dto.PageNumber = 99999; dto.PageSize = 99; var result = _controller.Get(dto) as NotFoundObjectResult; DtoResponseBase notification = (DtoResponseBase)result.Value; //assert Assert.IsNotNull(result); Assert.AreEqual(404, result.StatusCode); Assert.IsTrue(notification.Notifications[0].ErrorCode == 2); Assert.IsTrue(notification.Success == false); }
public void EntaoOStatuscodeDaRespostaDeveraSer(string statusCode) { var response = (IRestResponse)ScenarioContext.Current["Response"]; string errorMessage; switch (response.StatusCode) { case HttpStatusCode.Forbidden: var auth = response.Request.Parameters.Where(x => x.Name == "Authorization").FirstOrDefault(); errorMessage = "Authorization: " + (auth != null ? auth.Value : "none"); break; case HttpStatusCode.NotFound: errorMessage = "ReponseURI:" + response.ResponseUri; break; case HttpStatusCode.Unauthorized: errorMessage = "ReponseURI:" + response.ResponseUri; break; default: errorMessage = response.Content; break; } Assert.AreEqual(statusCode, response.StatusCode.ToString(), errorMessage); if (response.StatusCode == HttpStatusCode.NotFound) { notification = JsonConvert.DeserializeObject <DtoResponseBase>(response.Content); Assert.IsTrue(notification.Notifications[0].ErrorCode == 2); Assert.IsTrue(notification.Notifications[0].Description == "Nenhum item encontrado com os parâmetros informados."); Assert.IsTrue(notification.Success == false); } }