コード例 #1
0
        public void ShouldReturnBuildDefinitions()
        {
            // arrange
            const string project             = "StricklandPropaneTanks";
            const string buildDefinitionName = "StricklandPropaneSpatulas";
            const int    buildDefinitionId   = 234;

            IBuildDefinitionsFactory buildDefinitionsFactory = new FakeBuildDefinitionsFactory(1, new List <Definition> {
                new Definition(buildDefinitionId, buildDefinitionName)
            });
            BuildDefinitionController buildDefinitionController = new Privateer().Object <BuildDefinitionController>(buildDefinitionsFactory);

            // act
            OkObjectResult okObjectResult = (OkObjectResult)buildDefinitionController.BuildDefinitions(project);

            // assert
            okObjectResult.StatusCode.Should().Be(200);
            BuildDefinitions buildDefinitions = (BuildDefinitions)okObjectResult.Value;
            JObject          jObject          = JObject.Parse(JsonConvert.SerializeObject(buildDefinitions));

            jObject["count"].Value <int>().Should().Be(1);
            jObject["items"].Should().HaveCount(1);
            jObject["items"][0]["id"].Value <int>().Should().Be(buildDefinitionId);
            jObject["items"][0]["name"].Value <string>().Should().Be(buildDefinitionName);
        }
コード例 #2
0
        public void GivenEmptyProjectName_ShouldThrowException()
        {
            string       project             = string.Empty;
            const string buildDefinitionName = "StricklandPropaneSpatulas";
            const int    buildDefinitionId   = 234;

            IBuildDefinitionsFactory buildDefinitionsFactory = new FakeBuildDefinitionsFactory(1, new List <Definition> {
                new Definition(buildDefinitionId, buildDefinitionName)
            });
            BuildDefinitionController buildDefinitionController = new Privateer().Object <BuildDefinitionController>(buildDefinitionsFactory);

            // act
            BadRequestResult badRequestResult = (BadRequestResult)buildDefinitionController.BuildDefinitions(project);

            // assert
            badRequestResult.StatusCode.Should().Be(400);
        }