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

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

            try
            {
                // Act
                await resultConfigClient.GetResultConfig(It.IsAny <string>());
            }
            catch (FailedToGetResourceException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
        }
示例#2
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);
        }
示例#3
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);
        }