public async Task CheckResult_ResponseIsEmpyErrorObject_ThrowsException() { HttpResponseMessage responseMessage = new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("{}") }; LineBotException exception = await ExceptionAssert.ThrowsUnknownError(async() => { await responseMessage.CheckResult(); }); }
public async Task CheckResult_ResponseIsNull_ThrowsException() { HttpResponseMessage responseMessage = new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, }; LineBotException exception = await ExceptionAssert.ThrowsUnknownError(async() => { await responseMessage.CheckResult(); }); Assert.AreEqual(HttpStatusCode.InternalServerError, exception.StatusCode); Assert.IsNotNull(exception.Details); Assert.AreEqual(0, exception.Details.Count()); }
public async Task CheckResult_ResponseIsError_ThrowsException() { HttpResponseMessage responseMessage = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent(File.ReadAllText(JsonDocuments.Error)) }; LineBotException exception = await ExceptionAssert.ThrowsAsync <LineBotException>("The request body has 2 error(s)", async() => { await responseMessage.CheckResult(); }); Assert.AreEqual(HttpStatusCode.BadRequest, exception.StatusCode); Assert.IsNotNull(exception.Details); List <ILineErrorDetails> details = exception.Details.ToList(); Assert.AreEqual("May not be empty", details[0].Message); Assert.AreEqual("messages[0].text", details[0].Property); Assert.AreEqual("Must be one of the following values: [text, image, video, audio, location, sticker, template, imagemap]", details[1].Message); Assert.AreEqual("messages[1].type", details[1].Property); }