public void GIVEN_multiple_input_metrics_AND_one_project_WHEN_estimating_time_to_completion_THEN_returned_number_of_work_days_depends_on_randomly_selected_metrics( IReadOnlyCollection <ThroughputPerDay> throughputs, Project project, Queue <int> selectedIndices, double expectedNumberOfDaysRequired) { var inputMetrics = ToInputMetrics(throughputs); var roadmap = new Roadmap(new[] { project }); randomNumberGeneratorMock .Setup(rng => rng.GetRandomIndex(throughputs.Count)) .Returns(selectedIndices.Dequeue); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); var estimations = estimator.Estimate(roadmap); Assert.Equal(2, estimations.Count); WorkEstimate roadmapWorkEstimate = estimations[0]; Assert.Equal("Roadmap", roadmapWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(expectedNumberOfDaysRequired, roadmapWorkEstimate); AssertEstimateIsDeterminate(roadmapWorkEstimate); WorkEstimate projectWorkEstimate = estimations[1]; Assert.Equal("Project", projectWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(expectedNumberOfDaysRequired, projectWorkEstimate); AssertEstimateIsDeterminate(projectWorkEstimate); }
public void GIVEN_one_input_metric_AND_one_project_WHEN_estimating_time_to_completion_THEN_return_number_of_work_days( ThroughputPerDay throughput, Project project, double expectedNumberOfDaysRequired) { var inputMetrics = ToInputMetrics(new[] { throughput }); var roadmap = new Roadmap(new[] { project }); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); var estimations = estimator.Estimate(roadmap); Assert.Equal(2, estimations.Count); WorkEstimate roadmapWorkEstimate = estimations[0]; Assert.Equal("Roadmap", roadmapWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(expectedNumberOfDaysRequired, roadmapWorkEstimate); AssertEstimateIsDeterminate(roadmapWorkEstimate); WorkEstimate projectWorkEstimate = estimations[1]; Assert.Equal("Project", projectWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(expectedNumberOfDaysRequired, roadmapWorkEstimate); AssertEstimateIsDeterminate(roadmapWorkEstimate); }
public void GIVEN_project_is_null_WHEN_estimating_time_to_completion_THEN_throw_ArgumentNullException() { var inputMetrics = ToInputMetrics(new[] { ToThroughput(1) }); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); void Call() => estimator.Estimate(null); Assert.Throws <ArgumentNullException>("roadmap", Call); }
public void GIVEN_no_input_metrics_WHEN_estimating_time_to_completion_THEN_throw_InvalidOperationException() { var inputMetrics = Array.Empty <InputMetric>(); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); void Call() => estimator.Estimate(someRoadmap); var actualException = Assert.Throws <InvalidOperationException>(Call); Assert.StartsWith("At least 1 datapoint of input metrics is required for estimation.", actualException.Message); }
public void GIVEN_completed_roadmap_WHEN_estimating_time_to_completion_THEN_throw_ArgumentOutOfRangeException() { var inputMetrics = ToInputMetrics(new[] { new ThroughputPerDay(1) }); var project = new Project(1); var roadmap = new Roadmap(new[] { project }); project.CompleteWorkItem(); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); void Call() => estimator.Estimate(roadmap); var actualException = Assert.Throws <ArgumentOutOfRangeException>("roadmap", Call); Assert.StartsWith("Roadmap should have work to be completed.", actualException.Message); }
public void GIVEN_all_input_metrics_with_zero_throughput_AND_some_project_WHEN_estimating_time_to_completion_THEN_return_indeterminate_with_lower_bound_estimate() { var inputMetrics = ToInputMetrics(new[] { ToThroughput(0) }); var estimator = new TimeTillCompletionEstimator(inputMetrics, randomNumberGeneratorMock.Object, someMaximumNumberOfIterations); var estimations = estimator.Estimate(someRoadmap); Assert.Equal(2, estimations.Count); WorkEstimate roadmapWorkEstimate = estimations[0]; Assert.Equal("Roadmap", roadmapWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(someMaximumNumberOfIterations, roadmapWorkEstimate); AssertExpectedNumberOfWorkingDaysIsIndeterminate(roadmapWorkEstimate); WorkEstimate projectWorkEstimate = estimations[1]; Assert.Equal("Project", projectWorkEstimate.Identifier); AssertExpectedNumberOfWorkingDaysIsEqual(someMaximumNumberOfIterations, projectWorkEstimate); AssertExpectedNumberOfWorkingDaysIsIndeterminate(projectWorkEstimate); }
public void GIVEN_multiple_input_metrics_AND_one_project_AND_truely_random_number_generator_WHEN_estimating_time_to_completion_THEN_return_number_of_work_days_in_range( IReadOnlyCollection <ThroughputPerDay> throughputs, Project project, double lowerBoundExpectedNumberOfDaysRequired, double upperBoundExpectedNumberOfDaysRequired) { var inputMetrics = ToInputMetrics(throughputs); var roadmap = new Roadmap(new[] { project }); var estimator = new TimeTillCompletionEstimator(inputMetrics, realRandomNumberGenerator, someMaximumNumberOfIterations); var estimations = estimator.Estimate(roadmap); Assert.Equal(2, estimations.Count); WorkEstimate roadmapWorkEstimate = estimations[0]; Assert.Equal("Roadmap", roadmapWorkEstimate.Identifier); Assert.InRange(roadmapWorkEstimate.EstimatedNumberOfWorkingDaysRequired, lowerBoundExpectedNumberOfDaysRequired, upperBoundExpectedNumberOfDaysRequired); AssertEstimateIsDeterminate(roadmapWorkEstimate); WorkEstimate projectWorkEstimate = estimations[1]; Assert.Equal("Project", projectWorkEstimate.Identifier); Assert.InRange(projectWorkEstimate.EstimatedNumberOfWorkingDaysRequired, lowerBoundExpectedNumberOfDaysRequired, upperBoundExpectedNumberOfDaysRequired); AssertEstimateIsDeterminate(projectWorkEstimate); }