Exemple #1
0
    public void annualResultsInvalidInputTest()
    {
        List <String> monthly = new List <String> {
            "Invalid", "Input", "Test", "", "", "", "", "", "", "", "", ""
        };
        List <int> expected = new List <int> {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };

        CollectionAssert.AreEqual(expected, CreateReportMock.getAnnualResults(monthly));
    }
Exemple #2
0
    public void annualResultsTest()
    {
        List <String> monthly = new List <String>();
        List <double> average = new List <double>();

        System.Random random = new System.Random();

        for (int i = 0; i < 12; i++)
        {
            String input = "";
            for (int j = 0; j < DateTime.DaysInMonth(DateTime.Today.Year, i + 1); j++)
            {
                int    number = random.Next(30, 300);
                String temp   = (j + 1).ToString("00") + "-" + (i + 1).ToString("00") + "-" + DateTime.Today.Year.ToString() + " " + number.ToString();
                if (j == 0)
                {
                    input = temp;
                    average.Add(number);
                }
                else
                {
                    input      += "\n";
                    input      += temp;
                    average[i] += number;
                }
            }
            monthly.Add(input);
            average[i] /= DateTime.DaysInMonth(DateTime.Today.Year, i + 1);
        }

        List <double> expected = CreateReportMock.getAnnualResults(monthly);
        double        eps      = 0.0001;

        for (int i = 0; i < 12; i++)
        {
            Assert.That(average[i], Is.InRange(expected[i] - eps, expected[i] + eps));
        }
    }