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

            httpService
            .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunMarkUpdateModel>()))
            .ReturnsAsync(httpResponseMessage);
            var       simRunClient = new SimRunClient(httpService.Object);
            Exception exception    = null;

            try
            {
                // Act
                await simRunClient.UnmarkSimRun(DependantResourceDataMocks.MockDependantResourceModel());
            }
            catch (FailedToUpdateResourceException e)
            {
                exception = e;
            }

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

            httpService
            .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunMarkUpdateModel>()))
            .ReturnsAsync(httpResponseMessage);
            var       simRunClient = new SimRunClient(httpService.Object);
            Exception exception    = null;

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

            // Assert
            Assert.Null(exception);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        public async void UnmarkScenario_NotFoundStatusCode_NoExceptionThrown()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.NotFound,
                Content    = new StringContent("Some error!")
            };
            var httpService = new Mock <IHttpService>();

            httpService
            .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <ScenarioModel>()))
            .ReturnsAsync(httpResponseMessage);
            var       scenarioClient = new ScenarioClient(httpService.Object);
            Exception exception      = null;

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

            // Assert
            Assert.Null(exception);
        }
コード例 #6
0
        public async void UnmarkProject_InvalidGrpcConntection_ThrowsException()
        {
            // Arrange
            var       dependantResourceModel = DependantResourceDataMocks.MockDependantResourceModel();
            Exception exception = null;

            using (var projectClient = new ProjectClient())
            {
                try
                {
                    // Act
                    await projectClient.UnmarkProject(dependantResourceModel);
                }
                catch (FailedToUpdateResourceException e)
                {
                    exception = e;
                }
            }

            // Assert
            Assert.NotNull(exception);
        }