public async Task BadRequestIsReturnedForCrazyRequests() { // Arrange AddTestdataToDatabase(); InquiryController controller = new InquiryController(DbContext); // Act HttpResponseMessage response = controller.GetCustomerResponse(100, null); string responseContent = await response.Content.ReadAsStringAsync(); HttpResponseMessage response2 = controller.GetCustomerResponse(-9000, ""); string responseContent2 = await response.Content.ReadAsStringAsync(); HttpResponseMessage response3 = controller.GetCustomerResponseByEmail(string.Empty); string responseContent3 = await response.Content.ReadAsStringAsync(); HttpResponseMessage response4 = controller.GetCustomerResponseById(-9000); string responseContent4 = await response.Content.ReadAsStringAsync(); HttpResponseMessage response5 = controller.GetCustomerResponse(int.MaxValue, string.Empty); string responseContent5 = await response.Content.ReadAsStringAsync(); // Assert Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, response2.StatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, response3.StatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, response4.StatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, response5.StatusCode); }
public async Task CanGetCustomerByEmail() { // Arrange AddTestdataToDatabase(); InquiryController controller = new InquiryController(DbContext); // Act HttpResponseMessage response = controller.GetCustomerResponseByEmail(testCustomer1.CustomerEmail); Customer result = JsonHelper.DeserializeJson <Customer>(await response.Content.ReadAsStringAsync()); // Assert AssertTestCustomer(result); }
public async Task BadRequestAndNotFoundIsReturnedWhenEmailIsNotMatchAsync() { // Arrange AddTestdataToDatabase(); InquiryController controller = new InquiryController(DbContext); // Act HttpResponseMessage response = controller.GetCustomerResponseByEmail("*****@*****.**"); string responseContent = await response.Content.ReadAsStringAsync(); // Assert Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.AreEqual(Constants.Search.ErrorMessages.NOT_FOUND, responseContent); }