Пример #1
0
        public void GetAllBuildConfigurationTemplates_OneTemplateFound_Returned()
        {
            // Arrange
            var teamCityCaller = A.Fake <ITeamCityCaller>();

            A.CallTo(() => teamCityCaller.GetFormat <BuildTypeWrapper>("/app/rest/buildTypes?locator=templateFlag:true"))
            .Returns(new BuildTypeWrapper
            {
                BuildType = new List <BuildConfiguration>
                {
                    new BuildConfiguration
                    {
                        Id = "bt2"
                    }
                }
            });

            var buildConfigurationTemplateRetriever = new BuildConfigurationTemplateRetriever(teamCityCaller);

            // Act
            var templates = buildConfigurationTemplateRetriever.GetAllBuildConfigurationTemplates();

            // Assert
            templates.Single().Id.Should().Be("bt2");
        }
Пример #2
0
        public void GetAllBuildConfigurationTemplates_NotFound_EmptyList()
        {
            // Arrange
            var teamCityCaller = A.Fake <ITeamCityCaller>();

            A.CallTo(() => teamCityCaller.GetFormat <BuildTypeWrapper>("/app/rest/buildTypes?locator=templateFlag:true"))
            .Throws(new HttpException(HttpStatusCode.NotFound, "NotFound"));

            var buildConfigurationTemplateRetriever = new BuildConfigurationTemplateRetriever(teamCityCaller);

            // Act
            var templates = buildConfigurationTemplateRetriever.GetAllBuildConfigurationTemplates();

            // Assert
            templates.Should().BeEmpty();
        }
Пример #3
0
        public void GetAllBuildConfigurationTemplates_BuildTypeWrapperIsNull_EmptyList()
        {
            // Arrange
            var teamCityCaller = A.Fake <ITeamCityCaller>();

            A.CallTo(() => teamCityCaller.GetFormat <BuildTypeWrapper>("/app/rest/buildTypes?locator=templateFlag:true"))
            .Returns(null);

            var buildConfigurationTemplateRetriever = new BuildConfigurationTemplateRetriever(teamCityCaller);

            // Act
            var templates = buildConfigurationTemplateRetriever.GetAllBuildConfigurationTemplates();

            // Assert
            templates.Should().BeEmpty();
        }
Пример #4
0
        public void GetAllBuildConfigurationTemplates_ExceptionThrown_ExceptionRethrown()
        {
            // Arrange
            var teamCityCaller = A.Fake <ITeamCityCaller>();

            A.CallTo(() => teamCityCaller.GetFormat <BuildTypeWrapper>("/app/rest/buildTypes?locator=templateFlag:true"))
            .Throws(new HttpException(HttpStatusCode.BadRequest, "BadRequest"));

            var buildConfigurationTemplateRetriever = new BuildConfigurationTemplateRetriever(teamCityCaller);

            // Act
            Action action = () => buildConfigurationTemplateRetriever.GetAllBuildConfigurationTemplates();

            // Assert
            action.ShouldThrow <HttpException>()
            .Where(_ => _.StatusCode == HttpStatusCode.BadRequest && _.StatusDescription == "BadRequest");
        }