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(); }
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 DeleteInstance_StorageReturnsSuccess() { // Arrange Guid instanceGuid = Guid.NewGuid(); string instanceOwnerId = "1337"; Instance expected = new Instance { InstanceOwner = new InstanceOwner { PartyId = instanceOwnerId }, Id = $"{instanceOwnerId}/{instanceGuid}" }; HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(expected), Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "1337"); HttpClient httpClient = new HttpClient(handlerMock.Object); InstanceAppSI target = new InstanceAppSI(platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, appSettingsOptions.Object); // Act Instance actual = await target.DeleteInstance(1337, Guid.NewGuid(), false); // Assert Assert.Equal("1337", actual.InstanceOwner.PartyId); handlerMock.VerifyAll(); }
public async Task UpdatePresentationTexts_SuccessfulCallToStorage() { // Arrange Guid instanceGuid = Guid.NewGuid(); int instanceOwnerId = 1337; Instance expected = new Instance { InstanceOwner = new InstanceOwner { PartyId = instanceOwnerId.ToString() }, Id = $"{instanceOwnerId}/{instanceGuid}" }; HttpResponseMessage httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(expected), Encoding.UTF8, "application/json"), }; InitializeMocks(httpResponseMessage, "presentationtexts"); HttpClient httpClient = new HttpClient(handlerMock.Object); InstanceAppSI target = new InstanceAppSI(platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, appSettingsOptions.Object); // Act await target.UpdatePresentationTexts(instanceOwnerId, instanceGuid, new PresentationTexts()); // Assert handlerMock.VerifyAll(); }