コード例 #1
0
        public void VLookupShouldReturnClosestStringValueBelowWhenRangeLookupIsTrue()
        {
            var func           = new VLookup();
            var args           = FunctionsHelper.CreateArgs("B", "A1:B2", 2, true);
            var parsingContext = ParsingContext.Create();

            parsingContext.Scopes.NewScope(RangeAddress.Empty);

            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            //provider.Stub(x => x.GetCellValue(WorksheetName,0, 0)).Return(new ExcelCell("A", null, 0, 0));
            //provider.Stub(x => x.GetCellValue(WorksheetName,0, 1)).Return(new ExcelCell(1, null, 0, 0));
            //provider.Stub(x => x.GetCellValue(WorksheetName,1, 0)).Return(new ExcelCell("C", null, 0, 0));
            //provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(new ExcelCell(4, null, 0, 0));

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return("A");
            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(1);
            provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return("C");
            provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(4);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);

            Assert.AreEqual(1, result.Result);
        }
コード例 #2
0
ファイル: RefAndLookupTests.cs プロジェクト: nxoxn/EPPlus
		public void VLookupWithInvalidArgumentReturnsPoundValue()
		{
			var func = new VLookup();
			var parsingContext = ParsingContext.Create();
			var args = FunctionsHelper.CreateArgs();
			var result = func.Execute(args, parsingContext);
			Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
		}
コード例 #3
0
ファイル: RefAndLookupTests.cs プロジェクト: nxoxn/EPPlus
		public void VLookupShouldReturnResultFromMatchingRow()
		{
			var func = new VLookup();
			var args = FunctionsHelper.CreateArgs(2, "A1:B2", 2);
			var parsingContext = ParsingContext.Create();
			parsingContext.Scopes.NewScope(RangeAddress.Empty);

			var provider = MockRepository.GenerateStub<ExcelDataProvider>();
			provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(1);
			provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(1);
			provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(2);
			provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(5);

			parsingContext.ExcelDataProvider = provider;
			var result = func.Execute(args, parsingContext);
			Assert.AreEqual(5, result.Result);
		}
コード例 #4
0
        public void VLookupShouldReturnResultFromMatchingRow()
        {
            var func           = new VLookup();
            var args           = FunctionsHelper.CreateArgs(2, "A1:B2", 2);
            var parsingContext = ParsingContext.Create();

            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(0, 0)).Return(new ExcelCell(3, null, 0, 0));
            provider.Stub(x => x.GetCellValue(0, 1)).Return(new ExcelCell(1, null, 0, 0));
            provider.Stub(x => x.GetCellValue(1, 0)).Return(new ExcelCell(2, null, 0, 0));
            provider.Stub(x => x.GetCellValue(1, 1)).Return(new ExcelCell(5, null, 0, 0));

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);

            Assert.AreEqual(5, result.Result);
        }
コード例 #5
0
        public void VLookupShouldReturnClosestValueBelowWhenRangeLookupIsTrue()
        {
            var func           = new VLookup();
            var args           = FunctionsHelper.CreateArgs(4, "A1:B2", 2, true);
            var parsingContext = ParsingContext.Create();

            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(0, 0)).Return(new ExcelCell(3, null, 0, 0));
            provider.Stub(x => x.GetCellValue(0, 1)).Return(new ExcelCell(1, null, 0, 0));
            provider.Stub(x => x.GetCellValue(1, 0)).Return(new ExcelCell(5, null, 0, 0));
            provider.Stub(x => x.GetCellValue(1, 1)).Return(new ExcelCell(4, null, 0, 0));

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);

            Assert.AreEqual(1, result.Result);
        }
コード例 #6
0
        public void VLookupShouldReturnClosestStringValueBelowWhenRangeLookupIsTrue()
        {
            var func           = new VLookup();
            var args           = FunctionsHelper.CreateArgs("B", "A1:B2", 2, true);
            var parsingContext = ParsingContext.Create();

            parsingContext.Scopes.NewScope(RangeAddress.Empty);

            var provider = A.Fake <ExcelDataProvider>();;

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns("A");
            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 2)).Returns(1);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns("C");
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 2)).Returns(4);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);

            Assert.AreEqual(1, result.Result);
        }
コード例 #7
0
        public void VLookupShouldReturnResultFromMatchingRow()
        {
            var func           = new VLookup();
            var args           = FunctionsHelper.CreateArgs(2, "A1:B2", 2);
            var parsingContext = ParsingContext.Create();

            parsingContext.Scopes.NewScope(RangeAddress.Empty);

            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(1);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 2)).Returns(1);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(2);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 2)).Returns(5);
            A.CallTo(() => provider.GetDimensionEnd(A <string> .Ignored)).Returns(new ExcelCellAddress(100, 10));

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);

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