Пример #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 resultConfigClient = new ResultConfigClient(
                httpService.Object
                );
            Exception exception = null;

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

            // Assert
            Assert.NotNull(exception);
        }
        public async void DeleteResource_ValidConfigId_NoExceptionThrown()
        {
            // Arrange
            var dependantResourceModel = new DependantResourceModel
            {
                ResourceType = ResourceTypeEnum.ResultConfig,
                ResourceId   = "e019f476-b413-4ee7-965b-a4c0389cd086"
            };
            var       httpService        = new HttpService(new HttpClient());
            var       resultConfigClient = new ResultConfigClient(httpService);
            Exception exception          = null;

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

            // Assert
            Assert.Null(exception);
        }
Пример #3
0
        public async void CreateDependantResultConfigResource_ValidResultConfigModel_ReturnsDependantResourceModel()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(MetadataModelDataMocks.MockFinishedMetadataModelJson)
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            httpService
            .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultConfigClient = new ResultConfigClient(httpService.Object);

            // Act
            var result = await resultConfigClient.CreateDependantResultConfigResource(
                ResultConfigModelDataMocks.MockResultConfigModel()
                );

            // Assert
            Assert.NotNull(result);
        }
Пример #4
0
        public async void CreateDependantResultConfigResource_ValidResultConfigId_ReturnsDependantResourceModel()
        {
            // Arrange
            var resultConfigId     = "2462a6b6-5e07-48b4-b3e3-b3b207d55f4e";
            var httpService        = new HttpService(new HttpClient());
            var resultConfigClient = new ResultConfigClient(
                httpService
                );

            // Act
            var result = await resultConfigClient.CreateDependantResultConfigResource(resultConfigId);

            // Assert
            Assert.NotNull(result);
        }
Пример #5
0
        public async void GetResultConfigsForMetadata_ValidMetadataId_ReturnsReultConfigModelList()
        {
            // Arrange
            var metadataId         = "4439722e-a6d0-4f7a-9d33-0cc5a2a66da0";
            var httpService        = new HttpService(new HttpClient());
            var resultConfigClient = new ResultConfigClient(
                httpService
                );

            // Act
            var result = await resultConfigClient.GetResultConfigsForMetadata(metadataId);

            // Assert
            Assert.NotEmpty(result);
        }
Пример #6
0
        public async void GetResultConfig_ValidResultConfigId_ReturnsReultConfigModel()
        {
            // Arrange
            var resultConfigId     = "2462a6b6-5e07-48b4-b3e3-b3b207d55f4e";
            var httpService        = new HttpService(new HttpClient());
            var resultConfigClient = new ResultConfigClient(
                httpService
                );

            // Act
            var result = await resultConfigClient.GetResultConfig(resultConfigId);

            // Assert
            Assert.NotNull(result);
        }
Пример #7
0
        public async void GetMetadataForProject_OkStatusCode_ReturnsMarkSessionModelList()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(ResultConfigModelDataMocks.MockResultConfigResponseModelListJson)
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultConfigClient = new ResultConfigClient(httpService.Object);

            // Act
            var result = await resultConfigClient.GetResultConfigsForMetadata(It.IsAny <string>());

            // Assert
            Assert.NotEmpty(result);
        }
Пример #8
0
        public async void GetMetadataForProject_NotFoundStatusCode_ReturnsEmptyList()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.NotFound,
                Content    = new StringContent("")
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultConfigClient = new ResultConfigClient(httpService.Object);

            // Act
            var result = await resultConfigClient.GetResultConfigsForMetadata(It.IsAny <string>());

            // Assert
            Assert.Empty(result);
        }
Пример #9
0
        public async void GetResultConfig_OkStatusCode_ReturnsResultConfigModel()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(ResultConfigModelDataMocks.MockResultConfigResponseModelJson)
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(httpResponseMessage);
            var resultConfigClient = new ResultConfigClient(httpService.Object);

            // Act
            var result = await resultConfigClient.GetResultConfig(It.IsAny <string>());

            // Assert
            Assert.NotNull(result);
        }