Пример #1
0
        public async void GetMetadataForProject_ValidProjectId_ReturnsMetadataModelList()
        {
            // Arrange
            var projectId      = "623be379-ed40-49f3-bdd8-416f8cd0faa6";
            var httpService    = new HttpService(new HttpClient());
            var metadataClient = new MetadataClient(
                httpService
                );

            // Act
            var result = await metadataClient.GetMetadataForProject(projectId);

            // Assert
            Assert.NotEmpty(result);
        }
        public async void GetMetadataForProject_OkStatusCode_ReturnsMarkSessionModelList()
        {
            // Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(MarkSessionModelDataMocks.MockMarkSessionModelListJson)
            };
            var httpService = new Mock <IHttpService>();

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

            // Act
            var result = await metadataClient.GetMetadataForProject(It.IsAny <string>());

            // Assert
            Assert.NotEmpty(result);
        }
        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 metadataClient = new MetadataClient(httpService.Object);

            // Act
            var result = await metadataClient.GetMetadataForProject(It.IsAny <string>());

            // Assert
            Assert.Empty(result);
        }