public void WeekNumWithReturnType1OrOmmittedReturnsCorrectValue() { // Test case with the a return type of 1 or an ommitted return type. var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date, 1), this.ParsingContext); var r2 = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(1, result.Result); Assert.AreEqual(1, r2.Result); }
public void WeekNumWithStringArgumentReturnsPoundValue() { // Test case where the input is a general string and empty string. var function = new Weeknum(); var date1 = "testString"; var date2 = string.Empty; var result = function.Execute(FunctionsHelper.CreateArgs(date1), this.ParsingContext); var r2 = function.Execute(FunctionsHelper.CreateArgs(date2), this.ParsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)r2.Result).Type); }
public void WeekNumShouldReturnCorrectResult() { var func = new Weeknum(); var dt1 = new DateTime(2012, 12, 31).ToOADate(); var dt2 = new DateTime(2012, 1, 1).ToOADate(); var dt3 = new DateTime(2013, 1, 20).ToOADate(); var r1 = func.Execute(FunctionsHelper.CreateArgs(dt1), _parsingContext); var r2 = func.Execute(FunctionsHelper.CreateArgs(dt2), _parsingContext); var r3 = func.Execute(FunctionsHelper.CreateArgs(dt3, 2), _parsingContext); Assert.AreEqual(53, r1.Result, "r1.Result was not 53, but " + r1.Result.ToString()); Assert.AreEqual(1, r2.Result, "r2.Result was not 1, but " + r2.Result.ToString()); Assert.AreEqual(3, r3.Result, "r3.Result was not 3, but " + r3.Result.ToString()); }
public void WeekNumWithNoFirstParameterAndInvalidReturnTypeReturnsPoundNA() { // Test case where the first param is null with an invalid return type. var function = new Weeknum(); var result = function.Execute(FunctionsHelper.CreateArgs(null, 5), this.ParsingContext); Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithFractionInStringReturnsZero() { var function = new Weeknum(); var date = "0.5"; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(0, result.Result); }
public void WeekNumWithNoInputReturnsPoundValue() { //Test case where there is no input into the weeknum function. var function = new Weeknum(); var result = function.Execute(FunctionsHelper.CreateArgs(), this.ParsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithNegativIntAndInvalidReturnTypeReturnsPoundNum() { // Test case where the first param is a negative integer and has an invalid // return type. var function = new Weeknum(); var result = function.Execute(FunctionsHelper.CreateArgs(-1, 5), this.ParsingContext); Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithStringReturnTypeReturnsPoundValue() { // Test case where the return type is a general string var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date, "testString"), this.ParsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithNonZeroIntegerArgumentReturnsCorrectValue() { //Test case where the input is a non-zero integer. var function = new Weeknum(); var date = 365; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(53, result.Result); }
public void WeekNumWithInvalidReturnTypeReturnsPoundNum() { // Test case with an invalid return type. var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date, 5), this.ParsingContext); Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithReturnType14ReturnsCorrectValue() { // Test case where the return type is 14. var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date, 14), this.ParsingContext); Assert.AreEqual(2, result.Result); }
public void WeekNumWithDateNotAsStringReturnsCorrectValue() { // Test case where the date is written not in string form. var function = new Weeknum(); var date = 1 / 5 / 2017; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(0, result.Result); }
public void WeekNumWithNegativeIntReturnsPoundNum() { // Test case where the input is a negative integer. var function = new Weeknum(); var date = -5; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type); }
public void WeekNumWithZeroIntegerReturnsZero() { //Test case where the input is zero. var function = new Weeknum(); var date = 0; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(0, result.Result); }
public void WeekNumWithNumericStringReturnTypeReturnsCorrectValue() { // Test case where the return type is in string format. var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date, "1"), this.ParsingContext); Assert.AreEqual(1, result.Result); }
public void WeekNumWithOADateArgumentReturnsCorrectValue() { //Test case with the input as an OADate. var function = new Weeknum(); var date = new DateTime(2017, 1, 10).ToOADate(); var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(2, result.Result); }
public void WeekNumWithDateAsStringWithDashesReturnsCorrectResult() { // Test case where the input is a date is written with '-' instead of '/'. var function = new Weeknum(); var date = "1-10-2017"; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(2, result.Result); }
public void WeekNumWithDateAsStringReturnsCorrectResult() { //Test case where the input is a date written as a string. var function = new Weeknum(); var date = "1/10/2017"; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(2, result.Result); }
public void WeekNumWithDateFunctionInputReturnsCorrectResult() { //Test case where the input is a DateTime from the DateTime function. var function = new Weeknum(); var date = new DateTime(2017, 1, 5); var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(1, result.Result); }
public void WeekNumWithPeriodInsteadOfDashesOnUSCultureCorrecctValue() { // Test case where the input is the date written with '.' instead of '/'. //This functionality differs from Excel's. Excel normally returns a #VALUE! on the US //Culture, however the Weeknum class in EPPlus returns the week number. var function = new Weeknum(); var date = "1.5.2017"; var result = function.Execute(FunctionsHelper.CreateArgs(date), this.ParsingContext); Assert.AreEqual(1, result.Result); }
public void WeeknumFunctionWithErrorValuesAsInputReturnsTheInputErrorValue() { var func = new Weeknum(); 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); }