Beispiel #1
0
        public async void DeleteResource_InternalServerErrorStatusCode_ThrowsException()
        {
            // Arrange
            var httpService         = new Mock <IHttpService>();
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.InternalServerError,
                Content    = new StringContent("")
            };

            httpService
            .Setup(m => m.DeleteAsync(It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultDataClient = new ResultDataClient(
                httpService.Object
                );
            Exception exception = null;

            try
            {
                // Act
                await resultDataClient.DeleteResource(
                    DependantResourceDataMocks.MockDependantResourceModel()
                    );
            }
            catch (FailedToDeleteResourceException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
        }
Beispiel #2
0
        public async void DeleteResource_ValidResultDataId_NoExceptionThrown()
        {
            // Arrange
            var dependantResourceModel = new DependantResourceModel
            {
                ResourceType = ResourceTypeEnum.ResultData,
                ResourceId   = "7ada0dd6-0bd8-4872-9344-25555ca652a8"
            };
            var       httpService      = new HttpService(new HttpClient());
            var       resultDataClient = new ResultDataClient(httpService);
            Exception exception        = null;

            try
            {
                // Act
                await resultDataClient.DeleteResource(dependantResourceModel);
            }
            catch (Exception e)
            {
                exception = e;
            }

            // Assert
            Assert.Null(exception);
        }