public async Task UpdateReadStatus_StorageReturnsSuccess() { // Arrange Instance expected = new Instance { Status = new InstanceStatus { ReadStatus = ReadStatus.Read } }; HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(expected), Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "read"); HttpClient httpClient = new HttpClient(handlerMock.Object); InstanceAppSI target = new InstanceAppSI(platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, appSettingsOptions.Object); // Act Instance actual = await target.UpdateReadStatus(1337, Guid.NewGuid(), "read"); // Assert Assert.Equal(expected.Status.ReadStatus, actual.Status.ReadStatus); handlerMock.VerifyAll(); }
public async Task UpdateReadStatus_StorageReturnsNonSuccess_LogsErrorAppContinues() { // Arrange HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("Error message", Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "read"); 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.UpdateReadStatus(1337, Guid.NewGuid(), "read"); } catch (PlatformHttpException e) { actualException = e; } // Assert handlerMock.VerifyAll(); Assert.Null(actualException); }