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

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

            try
            {
                // Act
                await simRunClient.DeleteResource(
                    DependantResourceDataMocks.MockDependantResourceModel(),
                    It.IsAny <string>()
                    );
            }
            catch (FailedToGetResourceException e)
            {
                exception = e;
            }

            // Assert
            Assert.NotNull(exception);
        }
Esempio n. 2
0
        public async void DeleteResource_ValidSimRunId_NoExceptionThrown()
        {
            // Arrange
            var projectId = "be69cb8c-45e4-4d80-8d55-419984aa2151";
            var dependantResourceModel = new DependantResourceModel
            {
                ResourceType = ResourceTypeEnum.SimRun,
                ResourceId   = "5b07ddd052e35100015f04e4"
            };
            var       httpService  = new HttpService(new HttpClient());
            var       simRunClient = new SimRunClient(httpService);
            Exception exception    = null;

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

            // Assert
            Assert.Null(exception);
        }
Esempio n. 3
0
        public async void DeleteResource_OkStatusCode_NoExceptionThrown()
        {
            // Arrange
            var httpService         = new Mock <IHttpService>();
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("")
            };

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

            try
            {
                // Act
                await simRunClient.DeleteResource(
                    DependantResourceDataMocks.MockDependantResourceModel(),
                    It.IsAny <string>()
                    );
            }
            catch (Exception e)
            {
                exception = e;
            }

            // Asset
            Assert.Null(exception);
        }