Exemplo n.º 1
0
        public void Issue_delivery_based_on_throughput()
        {
            var sut = new Forecasting();

            var result = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 18), 10, _historicalData);

            foreach (var x in result.Entries)
            {
                _testOutputHelper.WriteLine($"{x.DaysUntilDelivery}\t{x.Probability}\t{x.Percentile}");
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            const int INITIAL_NUMBER_OF_ISSUES = 5;
            var       sut    = new Forecasting();
            var       issues = IssueRepository.Import().ToList();

            var cts             = issues.Select(x => x.CycleTime.Days).ToArray();
            var ctsDistribution = Statistics.Distribution(cts);

            Export("CTs 2019-11-06.csv", ctsDistribution);
            var tps             = issues.BusinessDayThroughputs();
            var tpsDistribution = Statistics.Distribution(tps);

            Export("TPs 2019-11-06.csv", tpsDistribution);


            // initial forecast
            var numberOfIssues = INITIAL_NUMBER_OF_ISSUES;
            var fc             = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 6), numberOfIssues, issues.ToArray());

            Export(new DateTime(2019, 11, 6), fc);

            // updating forecast after first issue got delivered
            issues.Add(new Issue(new DateTime(2019, 11, 6), new DateTime(2019, 11, 7), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 7), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 7), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 7), new DateTime(2019, 11, 8), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 8), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 8), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 6), new DateTime(2019, 11, 11), null, null, false));
            numberOfIssues += -1 + 2;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 11), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 11), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 11), new DateTime(2019, 11, 13), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 13), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 13), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 8), new DateTime(2019, 11, 14), null, null, false));
            numberOfIssues += -1 + 1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 14), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 14), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 11), new DateTime(2019, 11, 15), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 15), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 15), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 13), new DateTime(2019, 11, 18), null, null, false));
            numberOfIssues += -1 + 2;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 18), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 18), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 15), new DateTime(2019, 11, 19), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 19), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 19), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 18), new DateTime(2019, 11, 20), null, null, false));
            numberOfIssues += -1;
            fc              = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 20), numberOfIssues, issues.ToArray());
            Export(new DateTime(2019, 11, 20), fc);

            issues.Add(new Issue(new DateTime(2019, 11, 18), new DateTime(2019, 11, 21), null, null, false));
            numberOfIssues += -1;
            Assert.Equal(0, numberOfIssues);

            // rear mirror wisdom
            fc = sut.WhenWillTheIssuesBeDone(new DateTime(2019, 11, 6), INITIAL_NUMBER_OF_ISSUES + 5, issues.ToArray());
            File.Move("2019-11-06.csv", "2019-11-06-v1.csv", true);
            Export(new DateTime(2019, 11, 6), fc);
            File.Move("2019-11-06.csv", "2019-11-06-v2.csv", true);

            cts             = issues.Select(x => x.CycleTime.Days).ToArray();
            ctsDistribution = Statistics.Distribution(cts);
            Export("CTs 2019-11-21.csv", ctsDistribution);
            tps             = issues.BusinessDayThroughputs();
            tpsDistribution = Statistics.Distribution(tps);
            Export("TPs 2019-11-21.csv", tpsDistribution);
        }