public void TestOutOfRangeValues(int m, int x, int y)
        {
            // Arrange
            var ff = new ForecastingFunction();

            // Act
            ff.Multiplier = m;
            var ex = Assert.Throws <Exception>(() => ff.Forecast(x, y));

            // Assert
            Assert.Equal("X or Y are outside the domain.", ex.Message);
        }
        public void TestForecastingFormula(int m, int x, int y, int exp)
        {
            // Arrange
            var ff = new ForecastingFunction();

            // Act
            ff.Multiplier = m;
            var act = ff.Forecast(x, y);

            // Assert
            Assert.Equal(exp, act);
        }
Example #3
0
        static void Main(string[] args)
        {
            var ff = new ForecastingFunction();

            //Test 1;
            try {
                // Multiplier is zero
                var result = ff.Forecast(-11, 11);  //expect: Exception!
                Console.WriteLine("Test failed!");
            }
            catch (Exception ex) {
                Console.WriteLine("Test passed!");
            }
            //Test 2;
            // Multiplier is 2, x is 25, y is 5, result
            try {
                ff.Multiplier = 2;
                var result = ff.Forecast(25, 5);
                Console.WriteLine("Test failed!");
            }
            catch (Exception ex) {
                Console.WriteLine("Test passed!");
            }
            {
                ff.Multiplier = 2;
                var result = ff.Forecast(2, 2);
                if (result == 24)
                {
                    Console.WriteLine("Test passed!");
                }
                else
                {
                    Console.WriteLine("Test failed!");
                }
            }
        }
Example #4
0
 public void Init()
 {
     ff = new ForecastingFunction();
 }
Example #5
0
 public void TestInit()
 {
     ff = new ForecastingFunction();     // now it's instantiated
 }
Example #6
0
 public void TestInit()
 {
     ff = new ForecastingFunction();  //allows to create instance just 1 time
 }