Example #1
0
        public void Should_Return_ExcelLookupNavigator_When_Range_Is_Set()
        {
            var args      = new LookupArguments(FunctionsHelper.CreateArgs(8, "A:B", 1));
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Horizontal, args, _context);

            Assert.IsInstanceOfType(navigator, typeof(ExcelLookupNavigator));
        }
Example #2
0
        public void Should_Return_ArrayLookupNavigator_When_Array_Is_Supplied()
        {
            var args      = new LookupArguments(FunctionsHelper.CreateArgs(8, FunctionsHelper.CreateArgs(1, 2), 1));
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Horizontal, args, _context);

            Assert.IsInstanceOfType(navigator, typeof(ArrayLookupNavigator));
        }
        public void MoveNextShouldReturnFalseIfLastCell()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(4);
            var args      = GetArgs(3, "A1:B1", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.IsFalse(navigator.MoveNext());
        }
        public void CurrentValueShouldBeFirstCell()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(4);
            var args      = GetArgs(3, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(3, navigator.CurrentValue);
        }
        public void GetLookupValueShouldReturnCorrespondingValueWithOffset()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 3, 3)).Return(4);
            var args      = new LookupArguments(3, "A1:A4", 3, 2, false);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(4, navigator.GetLookupValue());
        }
        public void GetLookupValueShouldReturnCorrespondingValue()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(4);
            var args      = GetArgs(6, "A1:B2", 2);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(4, navigator.GetLookupValue());
        }
Example #7
0
        public void MoveNextShouldReturnFalseIfLastCell()
        {
            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(4);
            var args      = GetArgs(3, "A1:B1", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.IsFalse(navigator.MoveNext());
        }
Example #8
0
        public void CurrentValueShouldBeFirstCell()
        {
            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(4);
            var args      = GetArgs(3, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(3, navigator.CurrentValue);
        }
        public void HasNextShouldBeTrueIfNotLastCell()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetDimensionEnd(Arg <string> .Is.Anything)).Return(new ExcelCellAddress(5, 5));
            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(4);
            var args      = GetArgs(3, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.IsTrue(navigator.MoveNext());
        }
Example #10
0
        public void GetLookupValueShouldReturnCorrespondingValueWithOffset()
        {
            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetDimensionEnd(A <string> .Ignored)).Returns(new ExcelCellAddress(5, 5));
            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 3, 3)).Returns(4);
            var args      = new LookupArguments(3, "A1:A4", 3, 2, false, null);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(4, navigator.GetLookupValue());
        }
Example #11
0
        public void HasNextShouldBeTrueIfNotLastCell()
        {
            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetDimensionEnd(A <string> .Ignored)).Returns(new ExcelCellAddress(5, 5));
            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(4);
            var args      = GetArgs(3, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.IsTrue(navigator.MoveNext());
        }
        public void MoveNextShouldIncreaseIndex()
        {
            var provider = MockRepository.GenerateStub <ExcelDataProvider>();

            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
            provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(4);
            var args      = GetArgs(6, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            Assert.AreEqual(0, navigator.Index);
            navigator.MoveNext();
            Assert.AreEqual(1, navigator.Index);
        }
Example #13
0
        public void MoveNextShouldNavigateVertically()
        {
            var provider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(4);
            A.CallTo(() => provider.GetDimensionEnd(A <string> .Ignored)).Returns(new ExcelCellAddress(100, 10));
            var args      = GetArgs(6, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));

            navigator.MoveNext();
            Assert.AreEqual(4, navigator.CurrentValue);
        }