public void HourShouldReturnCorrectResult()
        {
            var func = new Hour();
            var result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 13, 14)), _parsingContext);
            Assert.AreEqual(9, result.Result);

            result = func.Execute(FunctionsHelper.CreateArgs(GetTime(23, 13, 14)), _parsingContext);
            Assert.AreEqual(23, result.Result);
        }
Exemplo n.º 2
0
        public void HourShouldReturnCorrectResult()
        {
            var func   = new Hour();
            var result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 13, 14)), _parsingContext);

            Assert.AreEqual(9, result.Result);

            result = func.Execute(FunctionsHelper.CreateArgs(GetTime(23, 13, 14)), _parsingContext);
            Assert.AreEqual(23, result.Result);
        }
Exemplo n.º 3
0
        public void HourShouldReturnCorrectResultWithStringArgument()
        {
            var func   = new Hour();
            var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-27 10:11:12"), _parsingContext);

            Assert.AreEqual(10, result.Result);
        }
Exemplo n.º 4
0
        public void HourWithDateAndTimeAsDifferentStringAsInputReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("3/1/1900 8:47:32 PM");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(20, result.Result);
        }
Exemplo n.º 5
0
        public void HourWithDateAndTimeAsStringAsInputReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("2013-03-27 10:11:12");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(10, result.Result);
        }
Exemplo n.º 6
0
        public void HourWithTimeOnlyAsStringReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("6:28:48");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(6, result.Result);
        }
Exemplo n.º 7
0
        public void HourWithMaxTimeOnlyReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs(this.GetTime(23, 59, 59));
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(23, result.Result);
        }
Exemplo n.º 8
0
        public void HourWithDateAndTimeExpressedAsStringWithUnspecifiedAMPMReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("3/1/1900 8:47:32");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(8, result.Result);
        }
Exemplo n.º 9
0
        public void HourWithExcelEpochOADateReturnsCorrectResult()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs(1.0);
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(0, result.Result);
        }
Exemplo n.º 10
0
        public void HourWithNegativeOADateAsStringAsInputReturnsPoundNum()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("-1.25");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);
        }
Exemplo n.º 11
0
        public void HourWithInvalidArgumentReturnsPoundValue()
        {
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs();
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Exemplo n.º 12
0
        public void HourWithMaxTimeValueOnOADateAsInputReturnsCorrectResult()
        {
            var inputDateTime = new DateTime(1900, 3, 1, 23, 59, 59);
            var func          = new Hour();
            var args          = FunctionsHelper.CreateArgs(inputDateTime.ToOADate());
            var result        = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(23, result.Result);
        }
Exemplo n.º 13
0
        public void HourWithFractionAsInputReturnsCorrectResult()
        {
            // Note that 0.27 is the Excel OADate for 1/0/1900 (the special 0-date) at 6:28:48.
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs(0.27);
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(6, result.Result);
        }
Exemplo n.º 14
0
        public void HourWithOADateAsStringAsInputReturnsCorrectResult()
        {
            // Note that 61.27 is the Excel OADate for 3/1/1900 at 6:28:48.
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("61.27");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(6, result.Result);
        }
Exemplo n.º 15
0
        public void HourWithDateTimeObjectAsInputReturnsCorrectResult()
        {
            var inputDateTime = new DateTime(1900, 3, 1, 8, 47, 32);
            var func          = new Hour();
            var args          = FunctionsHelper.CreateArgs(inputDateTime);
            var result        = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(8, result.Result);
        }
Exemplo n.º 16
0
        public void HourAsStringWithSixthDecimalPlaceProperlyRoundsDown()
        {
            // Note that Excel's max time value only goes out to 5 decimal places;
            // The 6th decimal place is rounded up if greater than or equal to 5,
            // and rounded down if less than 5.
            // Without the 6th decimal place, 61.99999 is the max date and time value for 3/1/1900 23:59:59.
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("61.999994");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(23, result.Result);
        }
Exemplo n.º 17
0
        public void HourAsStringWithFractionAsInputProperlyRoundsUpToExcelEpochDate()
        {
            // Note that Excel's max time value only goes out to 5 decimal places;
            // The 6th decimal place is rounded up if greater than or equal to 5,
            // and rounded down if less than 5.
            // 0.99999 is the max date and time value for 1/0/1900 (the special 0-date) at 23:59:59.
            var func   = new Hour();
            var args   = FunctionsHelper.CreateArgs("0.999995");
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(0, result.Result);
        }
Exemplo n.º 18
0
        public void HourFunctionWithErrorValuesAsInputReturnsTheInputErrorValue()
        {
            var func        = new Hour();
            var argNA       = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.NA));
            var argNAME     = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Name));
            var argVALUE    = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Value));
            var argNUM      = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Num));
            var argDIV0     = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Div0));
            var argREF      = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Ref));
            var resultNA    = func.Execute(argNA, this.ParsingContext);
            var resultNAME  = func.Execute(argNAME, this.ParsingContext);
            var resultVALUE = func.Execute(argVALUE, this.ParsingContext);
            var resultNUM   = func.Execute(argNUM, this.ParsingContext);
            var resultDIV0  = func.Execute(argDIV0, this.ParsingContext);
            var resultREF   = func.Execute(argREF, this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)resultNA.Result).Type);
            Assert.AreEqual(eErrorType.Name, ((ExcelErrorValue)resultNAME.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)resultVALUE.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)resultNUM.Result).Type);
            Assert.AreEqual(eErrorType.Div0, ((ExcelErrorValue)resultDIV0.Result).Type);
            Assert.AreEqual(eErrorType.Ref, ((ExcelErrorValue)resultREF.Result).Type);
        }
 public void HourShouldReturnCorrectResultWithStringArgument()
 {
     var func = new Hour();
     var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-27 10:11:12"), _parsingContext);
     Assert.AreEqual(10, result.Result);
 }