Beispiel #1
0
        public void Should_return_source_when_days_is_null()
        {
            // Given
            var function = new AddDaysFunction();
            var source   = new DateTime(2017, 9, 15, 9, 10, 0);

            // When
            var result = function.Evaluate(source, null);

            // Then
            Assert.That(result, Is.EqualTo(source));
        }
Beispiel #2
0
        public void Should_return_null_when_source_is_null()
        {
            // Given
            var function = new AddDaysFunction();
            var source   = (DateTime?)null;

            // When
            var result = function.Evaluate(source, "3");

            // Then
            Assert.That(result, Is.Null);
        }
Beispiel #3
0
        public void Should_add_days_to_date()
        {
            // Given
            var function = new AddDaysFunction();
            var source   = new DateTime(2017, 9, 15, 9, 10, 0);

            // When
            var result = function.Evaluate(source, "3");

            // Then
            Assert.That(result, Is.EqualTo(source.AddDays(3)));
        }
Beispiel #4
0
        public void Should_add_partial_days_to_date()
        {
            // Given
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var function = new AddDaysFunction();
            var source   = new DateTime(2017, 9, 15, 9, 10, 0);

            // When
            var result = function.Evaluate(source, "3.5");

            // Then
            Assert.That(result, Is.EqualTo(source.AddDays(3.5)));
        }
Beispiel #5
0
        public void SuccessfullySetFunctionInfo()
        {
            var function = new AddDaysFunction();

            Assert.NotNull(function.FunctionInfo);
            Assert.Equal("Add Days", function.FunctionInfo.Name);
            Assert.Equal(new Version("1.0.0"), function.FunctionInfo.Version);
            Assert.Equal("Calculates the date that is a number of days from a certain date.", function.FunctionInfo.Description);
            Assert.Collection(function.FunctionInfo.Tags,
                              i => Assert.Equal("date", i),
                              i => Assert.Equal("add", i),
                              i => Assert.Equal("day", i));
        }
        public void SuccessfullyReturnWithDefaultValues()
        {
            var function = new AddDaysFunction();

            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(Math.IEEERemainder(0.0, 1.0), TypeConverter.ToObject <double>(i.Value));
            });
        }