Ejemplo n.º 1
0
        public void AddStrategy_Compute_HandlesDoubleMaxValuesWithZero()
        {
            AddStrategy   strategy = new AddStrategy();
            List <double> inputs   = new List <double> {
                0, double.MaxValue
            };

            Assert.DoesNotThrowAsync(() => strategy.Compute(inputs), Resources.ListOutOfRange);
        }
Ejemplo n.º 2
0
        public void AddStrategy_Compute_HandlesDoubleMaxValues()
        {
            AddStrategy   strategy = new AddStrategy();
            List <double> inputs   = new List <double> {
                double.MaxValue, double.MaxValue
            };

            Assert.ThrowsAsync <CalculatorException>(() => strategy.Compute(inputs));
        }
Ejemplo n.º 3
0
        public async Task AddStrategy_Compute_HandlesNegativeValues()
        {
            AddStrategy   strategy = new AddStrategy();
            List <double> inputs   = new List <double> {
                -1, 2, -4, 1, 7, 0, 8, 0, 12, 5730203
            };
            var result = await strategy.Compute(inputs);

            Assert.AreEqual(5730228, result, 0.00000001); // The tolerance delta used here is due to the fact that double is used instead of decimal for speed
        }
Ejemplo n.º 4
0
        public async Task AddStrategy_Compute_ReturnsCorrectResult()
        {
            AddStrategy   strategy = new AddStrategy();
            List <double> inputs   = new List <double> {
                3, 4.2, 6
            };
            var result = await strategy.Compute(inputs);

            Assert.AreEqual(13.2, result, 0.00000001); // The tolerance delta used here is due to the fact that double is used instead of decimal for speed
        }
Ejemplo n.º 5
0
        public void AddStrategy_Compute_HandlesNullInput()
        {
            AddStrategy strategy = new AddStrategy();

            Assert.ThrowsAsync <CalculatorException>(() => strategy.Compute(MockInputs.NullList));
        }