public async Task AddCompleteConfirmation_StorageReturnsNonSuccess_ThrowsPlatformHttpException() { // Arrange HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("Error message", Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "complete"); HttpClient httpClient = new HttpClient(handlerMock.Object); InstanceAppSI target = new InstanceAppSI(platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, appSettingsOptions.Object); PlatformHttpException actualException = null; // Act try { await target.AddCompleteConfirmation(1337, Guid.NewGuid()); } catch (PlatformHttpException e) { actualException = e; } // Assert handlerMock.VerifyAll(); Assert.NotNull(actualException); }
public async Task AddCompleteConfirmation_SuccessfulCallToStorage() { // Arrange Instance instance = new Instance { CompleteConfirmations = new List <CompleteConfirmation> { new CompleteConfirmation { StakeholderId = "test" } } }; HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(instance), Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "complete"); HttpClient httpClient = new HttpClient(handlerMock.Object); InstanceAppSI target = new InstanceAppSI(platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, appSettingsOptions.Object); // Act await target.AddCompleteConfirmation(1337, Guid.NewGuid()); // Assert handlerMock.VerifyAll(); }