Пример #1
0
        public void FromCompileResultString()
        {
            var compileResult = new CompileResult("abc", DataType.String);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(StringExpression));
            Assert.AreEqual("abc", result.Compile().Result);
        }
Пример #2
0
        public void FromCompileResultTimeString()
        {
            var compileResult = new CompileResult("1000", DataType.Time);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(DecimalExpression));
            Assert.AreEqual(1000d, result.Compile().Result);
        }
Пример #3
0
        public void FromCompileResultDecimalUnknown()
        {
            var compileResult = new CompileResult(2.5, DataType.Unknown);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(DecimalExpression));
            Assert.AreEqual(2.5d, result.Compile().Result);
        }
Пример #4
0
        public void FromCompileResultIntegerUnknown()
        {
            var compileResult = new CompileResult(1, DataType.Unknown);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(IntegerExpression));
            Assert.AreEqual(1d, result.Compile().Result);
        }
Пример #5
0
        public void FromCompileResultExcelAddress()
        {
            var compileResult = new CompileResult("Sheet1!C3", DataType.ExcelAddress);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(StringExpression));
            Assert.AreEqual("Sheet1!C3", result.Compile().Result);
        }
Пример #6
0
        public void FromCompileResultExcelErrorUnknown()
        {
            var compileResult = new CompileResult(ExcelErrorValue.Parse("#N/A"), DataType.Unknown);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(ExcelErrorExpression));
            Assert.AreEqual(ExcelErrorValue.Parse("#N/A"), result.Compile().Result);
        }
Пример #7
0
        public void FromCompileResultEmpty()
        {
            var compileResult = new CompileResult("whatever", DataType.Empty);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(IntegerExpression));
            Assert.AreEqual(0d, result.Compile().Result);
        }
Пример #8
0
        public void FromCompileResultErrorTypeEnum()
        {
            var compileResult = new CompileResult(eErrorType.Value, DataType.ExcelError);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(ExcelErrorExpression));
            Assert.AreEqual(ExcelErrorValue.Parse("#VALUE!"), result.Compile().Result);
        }
Пример #9
0
        public void FromCompileResultDateUnknown()
        {
            var compileResult = new CompileResult(DateTime.Parse("1/1/2018"), DataType.Unknown);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(DateExpression));
            Assert.AreEqual(DateTime.Parse("1/1/2018"), result.Compile().Result);
        }
Пример #10
0
        public void FromCompileResultDateOADateString()
        {
            var compileResult = new CompileResult("12345", DataType.Date);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(DateExpression));
            Assert.AreEqual(DateTime.Parse("10/18/1933"), result.Compile().Result);
        }
Пример #11
0
        public void FromCompileResultBooleanUnknown()
        {
            var compileResult = new CompileResult(true, DataType.Unknown);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(BooleanExpression));
            Assert.AreEqual(true, result.Compile().Result);
        }
Пример #12
0
        public void FromCompileResultBooleanString()
        {
            var compileResult = new CompileResult("false", DataType.Boolean);
            var result        = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(BooleanExpression));
            Assert.AreEqual(false, result.Compile().Result);
        }
Пример #13
0
        public void FromCompileResultEnumerableListUnknown()
        {
            var compileResult = new CompileResult(new List <object> {
                1, 2, 3
            }, DataType.Unknown);
            var result = new ExpressionConverter().FromCompileResult(compileResult);

            Assert.IsInstanceOfType(result, typeof(IntegerExpression));
            Assert.AreEqual(1d, result.Compile().Result);
        }
Пример #14
0
 public void FromCompileResultEnumerableIntegerUnknown()
 {
     using (var package = new ExcelPackage())
     {
         var sheet = package.Workbook.Worksheets.Add("Sheet1");
         sheet.Cells["C1"].Value = 1;
         sheet.Cells["C2"].Value = 2;
         sheet.Cells["C3"].Value = 3;
         var dataProvider  = new EpplusExcelDataProvider(package);
         var range         = dataProvider.GetRange("Sheet1", 1, 3, 3, 3);
         var compileResult = new CompileResult(range, DataType.Unknown);
         var result        = new ExpressionConverter().FromCompileResult(compileResult);
         Assert.IsInstanceOfType(result, typeof(IntegerExpression));
         Assert.AreEqual(1d, result.Compile().Result);
     }
 }