Example #1
0
        public void MapToBuildStatus_SingleCompletedBuildItem_ReturnsCorrectBuildStatus(TfsBuildStatus tfsBuildStatus, TfsBuildResult tfsBuildResult, BuildStatus expected)
        {
            var sut = new TfsBuildItem {
                Status = tfsBuildStatus, Result = tfsBuildResult
            };

            var result = sut.MapToBuildStatus();

            Assert.AreEqual(expected, result);
        }
Example #2
0
        public void MapToBuildStatus_SingleInProgressBuildItem_ReturnsRunningBuildStatus()
        {
            var sut = new TfsBuildItem {
                Status = TfsBuildStatus.InProgress
            };

            var result = sut.MapToBuildStatus();

            Assert.AreEqual(BuildStatus.Running, result);
        }
Example #3
0
        public static BuildStatus MapToBuildStatus(this TfsBuildItem tfsBuildItem)
        {
            var buildStatus = BuildStatus.Unknown;

            if (tfsBuildItem != null)
            {
                switch (tfsBuildItem.Status)
                {
                case TfsBuildStatus.InProgress:
                    buildStatus = BuildStatus.Running;
                    break;

                case TfsBuildStatus.Completed:

                    switch (tfsBuildItem.Result)
                    {
                    case TfsBuildResult.Succeeded:
                        buildStatus = BuildStatus.Success;
                        break;

                    case TfsBuildResult.Failed:
                    case TfsBuildResult.PartiallySucceeded:
                        buildStatus = BuildStatus.Failure;
                        break;

                    case TfsBuildResult.None:
                    case TfsBuildResult.Canceled:
                        buildStatus = BuildStatus.Unknown;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(TfsBuildResult));
                    }
                    break;

                case TfsBuildStatus.None:
                case TfsBuildStatus.Cancelling:
                case TfsBuildStatus.Postponed:
                case TfsBuildStatus.NotStarted:
                case TfsBuildStatus.All:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(TfsBuildStatus));
                }
            }

            return(buildStatus);
        }