コード例 #1
0
        public async void MarkResultData_ConflictStatusCode_ThrowsException()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.Conflict,
                Content    = new StringContent("")
            };
            var httpService = new Mock <IHttpService>();

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

            try
            {
                // Act
                await resultDataClient.MarkResultData(It.IsAny <string>());
            }
            catch (ResourceAlreadyMarkedException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
        }
コード例 #2
0
        public async void UnmarkResultData_OkStatusCode_NoExceptionThrown()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("")
            };
            var httpService = new Mock <IHttpService>();

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

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

            // Assert
            Assert.Null(exception);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        public async void UnmarkResultData_MarkedResultDataModel_NoExceptionThrown()
        {
            // Arrange
            var dependantResourceModel = new DependantResourceModel(
                ResourceTypeEnum.ResultData,
                "c9de8a5e-1ab1-431f-a759-f44d7eef4e19"
                );
            var httpService      = new HttpService(new HttpClient());
            var resultDataClient = new ResultDataClient(
                httpService
                );
            Exception exception = null;

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

            // Assert
            Assert.Null(exception);
        }
コード例 #6
0
        public async void MarkResultData_UnmarkedResultDataModel_ReturnsDependantResourceModel()
        {
            // Arrange
            var resultDataId     = "4439722e-a6d0-4f7a-9d33-0cc5a2a66da0";
            var httpService      = new HttpService(new HttpClient());
            var resultDataClient = new ResultDataClient(
                httpService
                );

            // Act
            var result = await resultDataClient.MarkResultData(resultDataId);

            // Assert
            Assert.NotNull(result);
        }
コード例 #7
0
        public async void MarkResultData_OkStatusCode_ReturnsDependantResourceModel()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("")
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.PostAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultDataClient = new ResultDataClient(httpService.Object);

            // Act
            var result = await resultDataClient.MarkResultData(It.IsAny <string>());

            // Assert
            Assert.NotNull(result);
        }