private static BuildStatus? ConvertBuildStatus(BuildModel buildModel)
 {
     if (buildModel.Status == null)
         return null;
     BuildStatus result;
     if (!Enum.TryParse(buildModel.Status, true, out result))
         return null;
     return result;
 }
        public void ConvertToBuild()
        {
            var buildModelToBuildConverter = new BuildModelToBuildConverter();
            var buildModel = new BuildModel
            {
                Status = "FAILURE",
                BuildType = new BuildConfiguration {Id = "bt2"},
                BuildTypeId = "bt2"
            };
            var build = buildModelToBuildConverter.ConvertToBuild(buildModel);

            // Assert
            build.Status.Should().Be(BuildStatus.Failure);
            build.BuildConfiguration.Id.Should().Be("bt2");
        }
        public IBuild ConvertToBuild(BuildModel buildModel)
        {
            List<Change> changes = new List<Change>();

            if (buildModel.LastChanges != null)
            {
                changes = buildModel.LastChanges.Change;
            }
            else if (buildModel.Revisions != null)
            {
                changes = buildModel.Revisions.Revision;
            }

            var buildConfiguration = buildModel.BuildType ?? new BuildConfiguration { Id = buildModel.BuildTypeId };

            return new Build(buildModel.Id, buildModel.Number,
                ConvertBuildStatus(buildModel),
                buildModel.StartDate, buildModel.FinishDate, buildModel.QueuedDate, buildConfiguration,
                buildModel.Agent, changes, buildModel.WebUrl,
                buildModel.Properties, buildModel.TestOccurrences, ConvertBuildState(buildModel));
        }