public async Task ProcessSendInvite_Response_BadRequest() { HttpResponseMessage resp = this.GetHttpResponseMessage(HttpStatusCode.BadRequest, null); var handlerMock = new Mock <HttpMessageHandler>(); _ = handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(resp); var httpClient = new HttpClient(handlerMock.Object); var notificationId = Guid.NewGuid().ToString(); Exception ex = null; var msGrpahProvider = new MSGraphProvider(this.MsGraphSetting, Options.Create(this.retrySetting), this.Logger, httpClient); try { var result = await msGrpahProvider.SendMeetingInvite(this.TestTokenHeader, this.GetInvitePayload(), notificationId).ConfigureAwait(false); } catch (Exception e) { ex = e; } Assert.IsTrue(ex?.Message?.Contains($"An error occurred while sending notification id: {notificationId}")); }
public async Task ProcessSendInvite_Response_Null() { var notificationId = Guid.NewGuid().ToString(); Exception ex = null; var msGrpahProvider = new MSGraphProvider(this.MsGraphSetting, Options.Create(this.retrySetting), this.Logger, this.MockedHttpClient.Object); try { var result = await msGrpahProvider.SendMeetingInvite(this.TestTokenHeader, this.GetInvitePayload(), notificationId).ConfigureAwait(false); } catch (Exception e) { ex = e; } Assert.IsTrue(ex?.Message?.Contains($"An error occurred while sending notification id: {notificationId}")); }
public async Task ProcessSendInvite_RequestTimeout() { HttpResponseMessage resp = this.GetHttpResponseMessage(HttpStatusCode.RequestTimeout, null); var handlerMock = new Mock <HttpMessageHandler>(); _ = handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(resp); var httpClient = new HttpClient(handlerMock.Object); var notificationId = Guid.NewGuid().ToString(); var msGrpahProvider = new MSGraphProvider(this.MsGraphSetting, Options.Create(this.retrySetting), this.Logger, httpClient); var result = await msGrpahProvider.SendMeetingInvite(this.TestTokenHeader, this.GetInvitePayload(), notificationId).ConfigureAwait(false); Assert.AreEqual(result.StatusCode, HttpStatusCode.RequestTimeout); }