예제 #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));
        }
예제 #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));
        }
예제 #3
0
        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());
        }
예제 #4
0
        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);
        }
예제 #5
0
        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());
        }
예제 #6
0
        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());
        }
예제 #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());
        }
예제 #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);
        }
예제 #9
0
        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());
        }
예제 #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());
        }
예제 #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());
        }
예제 #12
0
        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);
        }
예제 #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);
        }