예제 #1
0
        public void FailWhenGivenDivisorOfZero()
        {
            var function = new ModuloFunction();

            var inputs = function.GetInputs();

            Assert.Throws <DivideByZeroException>(() =>
            {
                inputs[0].Value = 17;
                inputs[1].Value = 0;
            });
        }
예제 #2
0
        public void SuccessfullySetFunctionInfo()
        {
            var function = new ModuloFunction();

            Assert.NotNull(function.FunctionInfo);
            Assert.Equal("Modulo", function.FunctionInfo.Name);
            Assert.Equal(new Version("1.0.0"), function.FunctionInfo.Version);
            Assert.Equal("Find the C# standard remainder of two numbers.", function.FunctionInfo.Description);
            Assert.Collection(function.FunctionInfo.Tags,
                              i => Assert.Equal("algebra", i),
                              i => Assert.Equal("modulo", i),
                              i => Assert.Equal("remainder", i));
        }
예제 #3
0
        public void SuccessfullyReturnWithDefaultValues()
        {
            var function = new ModuloFunction();

            var inputs = function.GetInputs();

            Assert.Equal(2, inputs.Length);

            var result = function.Calculate(inputs);

            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(0, TypeConverter.ToObject <int>(i.Value));
            });
        }
예제 #4
0
        public void SuccessfullyReturnValueGivenDividendIsEqualToDivisor()
        {
            var function = new ModuloFunction();

            var inputs = function.GetInputs();

            Assert.Equal(2, inputs.Length);

            inputs[0].Value = 17;
            inputs[1].Value = 17;

            var result = function.Calculate(inputs);

            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(0, TypeConverter.ToObject <int>(i.Value));
            });
        }