Example #1
0
        public void WorkdayWithStringsAsHolidayInputReturnsPoundValue()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result1   = function.Execute(FunctionsHelper.CreateArgs(inputDate, 10, "testString"), this.ParsingContext);
            var result2   = function.Execute(FunctionsHelper.CreateArgs(inputDate, 10, ""), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result2.Result).Type);
        }
Example #2
0
        public void WorkdayWithStringInputReturnsPoundValue()
        {
            var function = new Workday();
            var input1   = "testString";
            var input2   = "";
            var result1  = function.Execute(FunctionsHelper.CreateArgs(input1, 10), this.ParsingContext);
            var result2  = function.Execute(FunctionsHelper.CreateArgs(input2, 10), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result1.Result).Type);
        }
Example #3
0
        public void WorkdayWithDayParameterAsGenericStringReturnsPoundValue()
        {
            var function   = new Workday();
            var daysInput1 = "testString";
            var daysInput2 = "";
            var startDate  = new DateTime(2017, 1, 1);
            var result     = function.Execute(FunctionsHelper.CreateArgs(startDate, daysInput1), this.ParsingContext);
            var result2    = function.Execute(FunctionsHelper.CreateArgs(startDate, daysInput2), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result2.Result).Type);
        }
Example #4
0
        public void WorkdayWithNullSecondParameterReturnsPoundNA()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs("1/2/2017", null), this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)result.Result).Type);
        }
Example #5
0
        public void WorkdayWithNullFirstParamReturnsPoundNum()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs(null, 10), this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)result.Result).Type);
        }
Example #6
0
        public void WorkdayDateWithSlashesFirstInputAndNegDateInputReturnsCorrectInput()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs("1-2-2017", -10), this.ParsingContext);

            Assert.AreEqual(42723.00, result.Result);
        }
Example #7
0
        public void WorkdayWithZeroFirstInputNegativeDateInputReturnsPoundNum()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs(0, -10), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);
        }
Example #8
0
        public void WorkdayWithEmptyFirstParameterAndNegativeDateInputReturnsPoundNA()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs(null, -10), this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)result.Result).Type);
        }
Example #9
0
        public void WorkdayWithHolidaysAsStringsReturnsCorrectValue()
        {
            var function = new Workday();
            var result   = function.Execute(FunctionsHelper.CreateArgs("1/2/2017", 41, "1/25/2017"), this.ParsingContext);

            Assert.AreEqual(42795.00, result.Result);
        }
Example #10
0
        public void WorkdayWithPositiveArgsAndNullHolidayDatesReturnsCorrectValue()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result    = function.Execute(FunctionsHelper.CreateArgs(inputDate, 10, null), this.ParsingContext);

            Assert.AreEqual(42751.00, result.Result);
        }
Example #11
0
        public void WorkdayWithZeroAsDateParameterReuturnsCorrectValeue()
        {
            var function  = new Workday();
            var startDate = new DateTime(2017, 1, 1);
            var result    = function.Execute(FunctionsHelper.CreateArgs(startDate, 0), this.ParsingContext);

            Assert.AreEqual(42736.00, result.Result);
        }
Example #12
0
        public void WorkdayWithDayParameterAsOADateReturnCorrectValue()
        {
            var function  = new Workday();
            var startDate = new DateTime(2017, 1, 1);
            var result    = function.Execute(FunctionsHelper.CreateArgs(startDate, 42748), this.ParsingContext);

            Assert.AreEqual(102582.00, result.Result);
        }
Example #13
0
        public void WorkdayWithNullDayParameterReturnsPoundNA()
        {
            var function  = new Workday();
            var startDate = new DateTime(2017, 1, 1);
            var result    = function.Execute(FunctionsHelper.CreateArgs(startDate, null), this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)result.Result).Type);
        }
Example #14
0
        public void WorkdayWithDateUsingDashesInsteadOfSlashesReturnsCorrectResult()
        {
            var function = new Workday();
            var input    = "1-2-2017";
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 10), this.ParsingContext);

            Assert.AreEqual(42751.00, result.Result);
        }
Example #15
0
        public void WorkdayWithDateAsStringReturnsCorrectValue()
        {
            var function = new Workday();
            var input    = "1/2/2017";
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 10), this.ParsingContext);

            Assert.AreEqual(42751.00, result.Result);
        }
Example #16
0
        public void WorkdayWithNegativeIntAsHolidayInputReturnsPoundNum()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result    = function.Execute(FunctionsHelper.CreateArgs(inputDate, 10, -1), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);
        }
Example #17
0
        public void WorkdayWithDATEFunctionAndNegativeDayInputReturnsCorrectResult()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result    = function.Execute(FunctionsHelper.CreateArgs(inputDate, -10), this.ParsingContext);

            Assert.AreEqual(42723.00, result.Result);
        }
Example #18
0
        public void WorkdayWithInvalidArgumentReturnsPoundValue()
        {
            var function = new Workday();
            var args     = FunctionsHelper.CreateArgs();
            var result   = function.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Example #19
0
        public void WorkdayWithIntegerInputReturnsCorrectValue()
        {
            var function = new Workday();
            var input    = 10;
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 10), this.ParsingContext);

            Assert.AreEqual(24.00, result.Result);
        }
Example #20
0
        public void WorkdayWithDATEFunctionAsInputReturnsCorrectValue()
        {
            var function = new Workday();
            var input    = new DateTime(2017, 1, 2);
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 10), this.ParsingContext);

            Assert.AreEqual(42751.00, result.Result);
        }
Example #21
0
        public void WorkdayWithNonZeroIntegerAsHolidayInputReturnsCorrectValue()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result    = function.Execute(FunctionsHelper.CreateArgs(inputDate, 5, 1), this.ParsingContext);

            Assert.AreEqual(42744.00, result.Result);
        }
Example #22
0
        public void WorkdayWithHolidayWithDashesInsteadOfSlashesReturnsCorrectValue()
        {
            var function  = new Workday();
            var inputDate = new DateTime(2017, 1, 2);
            var result    = function.Execute(FunctionsHelper.CreateArgs(inputDate, 41, "1-25-2017"), this.ParsingContext);

            Assert.AreEqual(42795.00, result.Result);
        }
Example #23
0
        public void WorkdayWithFractionAsStringInputReturnsCorrectValue()
        {
            var function = new Workday();
            var input    = "0.5";
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 15), this.ParsingContext);

            Assert.AreEqual(20.00, result.Result);
        }
Example #24
0
        public void WorkdayWithDayParameterTypedWithQuotesReturnsCorrectResult()
        {
            var function  = new Workday();
            var daysInput = "1/13/2017";
            var startDate = new DateTime(2017, 1, 1);
            var result    = function.Execute(FunctionsHelper.CreateArgs(startDate, daysInput), this.ParsingContext);

            Assert.AreEqual(102582.00, result.Result);
        }
Example #25
0
        public void WorkdayWithDayParameterWithDashInsteadOfSlashForDateReturnsCorrectValue()
        {
            var function  = new Workday();
            var startDate = new DateTime(2017, 1, 1);
            var dayInput  = "1-13-2017";
            var result    = function.Execute(FunctionsHelper.CreateArgs(startDate, dayInput), this.ParsingContext);

            Assert.AreEqual(102582.00, result.Result);
        }
Example #26
0
        public void WorkdayWithOADateParameterReturnsCorrectResult()
        {
            var inputDate    = new DateTime(2014, 1, 1).ToOADate();
            var expectedDate = new DateTime(2014, 1, 29).ToOADate();
            var function     = new Workday();
            var args         = FunctionsHelper.CreateArgs(inputDate, 20);
            var result       = function.Execute(args, this.ParsingContext);

            Assert.AreEqual(expectedDate, result.Result);
        }
Example #27
0
        public void WorkdayShouldReturnCorrectResultWithNegativeArg()
        {
            var inputDate    = new DateTime(2016, 6, 15).ToOADate();
            var expectedDate = new DateTime(2016, 5, 4).ToOADate();
            var func         = new Workday();
            var args         = FunctionsHelper.CreateArgs(inputDate, -30);
            var result       = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(DateTime.FromOADate(expectedDate), DateTime.FromOADate((double)result.Result));
        }
Example #28
0
        public void WorkdayShouldReturnCorrectResultWithFourDaysSupplied()
        {
            var inputDate    = new DateTime(2014, 1, 1).ToOADate();
            var expectedDate = new DateTime(2014, 1, 7).ToOADate();
            var function     = new Workday();
            var args         = FunctionsHelper.CreateArgs(inputDate, 4);
            var result       = function.Execute(args, this.ParsingContext);

            Assert.AreEqual(expectedDate, result.Result);
        }
Example #29
0
        public void WorkdayShouldReturnCorrectResultIfNoHolidayIsSupplied()
        {
            var inputDate    = new DateTime(2014, 1, 1).ToOADate();
            var expectedDate = new DateTime(2014, 1, 29).ToOADate();

            var func   = new Workday();
            var args   = FunctionsHelper.CreateArgs(inputDate, 20);
            var result = func.Execute(args, _parsingContext);

            Assert.AreEqual(expectedDate, result.Result);
        }
Example #30
0
        public void WorkdayWithDateUsingPeriodsInsteadOfSlashesReturnsCorrectValue()
        {
            // Test case where the first parameter is a date written as a string but with '.' in place of the '/'.
            // This functionality is different than that of Excel's. Excel normally returns a #VALUE! when this
            // is entered into the function but here the date is parsed normally.
            var function = new Workday();
            var input    = "1.2.2017";
            var result   = function.Execute(FunctionsHelper.CreateArgs(input, 10), this.ParsingContext);

            Assert.AreEqual(42751.00, result.Result);
        }