FakeItEasy.A.Fake()

Here are the examples of the csharp api FakeItEasy.A.Fake() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

539 Examples 7

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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));
            replacedert.AreEqual(3, navigator.CurrentValue);
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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));
            replacedert.IsTrue(navigator.MoveNext());
        }

19 View Source File : RowMatcherTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

private ExcelDatabaseCriteria GetCriteria(Dictionary<ExcelDatabaseCriteriaField, object> items)
        {
            var provider = A.Fake<ExcelDataProvider>();
            var criteria = A.Fake<ExcelDatabaseCriteria>();// (provider, string.Empty);

            A.CallTo(() => criteria.Items).Returns(items);
            return criteria;
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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();
            replacedert.AreEqual(4, navigator.CurrentValue);
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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));
            replacedert.IsFalse(navigator.MoveNext());
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void GetLookupValueShouldReturnCorrespondingValue()
        {
            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, 1, 2)).Returns(4);
            var args = GetArgs(6, "A1:B2", 2);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
            replacedert.AreEqual(4, navigator.GetLookupValue());
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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));
            replacedert.AreEqual(4, navigator.GetLookupValue());
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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);
            replacedert.AreEqual(5, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void VLookupShouldReturnClosestValueBelowWhenRangeLookupIsTrue()
        {
            var func = new VLookup();
            var args = FunctionsHelper.CreateArgs(4, "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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 2)).Returns(1);
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 1)).Returns(5);
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 2)).Returns(4);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(1, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeExact()
        {
            var func = new Match();
            var args = FunctionsHelper.CreateArgs(3, "A1:C1", 0);
            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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeClosestBelow()
        {
            var func = new Match();
            var args = FunctionsHelper.CreateArgs(4, "A1:C1", 1);
            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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeClosestAbove()
        {
            var func = new Match();
            var args = FunctionsHelper.CreateArgs(6, "A1:C1", -1);
            var parsingContext = ParsingContext.Create();
            parsingContext.Scopes.NewScope(RangeAddress.Empty);

            var provider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 1)).Returns(10);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 2)).Returns(8);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MatchShouldReturnFirsreplacedemWhenExactMatch_MatchTypeClosestAbove()
        {
            var func = new Match();
            var args = FunctionsHelper.CreateArgs(10, "A1:C1", -1);
            var parsingContext = ParsingContext.Create();
            parsingContext.Scopes.NewScope(RangeAddress.Empty);

            var provider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 1)).Returns(10);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 2)).Returns(8);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(1, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void RowShouldReturnRowFromCurrentScopeIfNoAddressIsSupplied()
        {
            var func = new Row();
            var parsingContext = ParsingContext.Create();
            var rangeAddressFactory = new RangeAddressFactory(A.Fake<ExcelDataProvider>());
            parsingContext.Scopes.NewScope(rangeAddressFactory.Create("A2"));
            var result = func.Execute(Enumerable.Empty<FunctionArgument>(), parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void RowShouldReturnRowSuppliedAddress()
        {
            var func = new Row();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            var result = func.Execute(FunctionsHelper.CreateArgs("A3"), parsingContext);
            replacedert.AreEqual(3, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ColumnShouldReturnRowFromCurrentScopeIfNoAddressIsSupplied()
        {
            var func = new Column();
            var parsingContext = ParsingContext.Create();
            var rangeAddressFactory = new RangeAddressFactory(A.Fake<ExcelDataProvider>());
            parsingContext.Scopes.NewScope(rangeAddressFactory.Create("B2"));
            var result = func.Execute(Enumerable.Empty<FunctionArgument>(), parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ColumnShouldReturnRowSuppliedAddress()
        {
            var func = new Column();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            var result = func.Execute(FunctionsHelper.CreateArgs("E3"), parsingContext);
            replacedert.AreEqual(5, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void RowsShouldReturnNbrOfRowsSuppliedRange()
        {
            var func = new Rows();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            var result = func.Execute(FunctionsHelper.CreateArgs("A1:B3"), parsingContext);
            replacedert.AreEqual(3, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void RowsShouldReturnNbrOfRowsForEntireColumn()
        {
            var func = new Rows();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            var result = func.Execute(FunctionsHelper.CreateArgs("A:B"), parsingContext);
            replacedert.AreEqual(1048576, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ColumnssShouldReturnNbrOfRowsSuppliedRange()
        {
            var func = new Columns();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            var result = func.Execute(FunctionsHelper.CreateArgs("A1:E3"), parsingContext);
            replacedert.AreEqual(5, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void AddressShouldReturnAddressByIndexWithDefaultRefType()
        {
            var func = new AddressFunction();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => parsingContext.ExcelDataProvider.ExcelMaxRows).Returns(10);
            var result = func.Execute(FunctionsHelper.CreateArgs(1, 2), parsingContext);
            replacedert.AreEqual("$B$1", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void AddressShouldReturnAddressByIndexWithRelativeType()
        {
            var func = new AddressFunction();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => parsingContext.ExcelDataProvider.ExcelMaxRows).Returns(10);
            var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn), parsingContext);
            replacedert.AreEqual("B1", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void AddressShouldReturnAddressByWithSpecifiedWorksheet()
        {
            var func = new AddressFunction();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => parsingContext.ExcelDataProvider.ExcelMaxRows).Returns(10);
            var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn, true, "Worksheet1"), parsingContext);
            replacedert.AreEqual("Worksheet1!B1", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod, ExpectedException(typeof(InvalidOperationException))]
        public void AddressShouldThrowIfR1C1FormatIsSpecified()
        {
            var func = new AddressFunction();
            var parsingContext = ParsingContext.Create();
            parsingContext.ExcelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => parsingContext.ExcelDataProvider.ExcelMaxRows).Returns(10);
            var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn, false), parsingContext);
        }

19 View Source File : LookupNavigatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MoveNextShouldIncreaseIndex()
        {
            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, 1, 2)).Returns(4);
            var args = GetArgs(6, "A1:B2", 1);
            var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
            replacedert.AreEqual(0, navigator.Index);
            navigator.MoveNext();
            replacedert.AreEqual(1, navigator.Index);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        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);
            replacedert.AreEqual(1, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void HLookupShouldReturnResultFromMatchingRow()
        {
            var func = new HLookup();
            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);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(5, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void HLookupShouldReturnNaErrorIfNoMatchingRecordIsFoundWhenRangeLookupIsFalse()
        {
            var func = new HLookup();
            var args = FunctionsHelper.CreateArgs(2, "A1:B2", 2, false);
            var parsingContext = ParsingContext.Create();
            parsingContext.Scopes.NewScope(RangeAddress.Empty);

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

            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 1)).Returns(3);
            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);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            var expectedResult = ExcelErrorValue.Create(eErrorType.NA);
            replacedert.AreEqual(expectedResult, result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void HLookupShouldReturnErrorIfNoMatchingRecordIsFoundWhenRangeLookupIsTrue()
        {
            var func = new HLookup();
            var args = FunctionsHelper.CreateArgs(1, "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(2);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 1, 2)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName, 2, 2)).Returns(5);

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(result.DataType, DataType.ExcelError);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void LookupShouldReturnResultFromMatchingRowArrayVertical()
        {
            var func = new Lookup();
            var args = FunctionsHelper.CreateArgs(4, "A1:B3", 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("A");
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 2)).Returns("B");
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 1)).Returns(5);
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 2)).Returns("C");
            A.CallTo(() => provider.GetDimensionEnd(A<string>.Ignored)).Returns(new ExcelCellAddress(100, 10));

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual("B", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void LookupShouldReturnResultFromMatchingRowArrayHorizontal()
        {
            var func = new Lookup();
            var args = FunctionsHelper.CreateArgs(4, "A1:C2", 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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 1)).Returns("A");
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 2)).Returns("B");
            A.CallTo(() => provider.GetCellValue(WorksheetName,2, 3)).Returns("C");

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual("B", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void LookupShouldReturnResultFromMatchingSecondArrayHorizontal()
        {
            var func = new Lookup();
            var args = FunctionsHelper.CreateArgs(4, "A1:C1", "A3:C3");
            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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 1)).Returns("A");
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 2)).Returns("B");
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 3)).Returns("C");

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual("B", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void LookupShouldReturnResultFromMatchingSecondArrayHorizontalWithOffset()
        {
            var func = new Lookup();
            var args = FunctionsHelper.CreateArgs(4, "A1:C1", "B3:D3");
            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(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,1, 3)).Returns(5);
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 2)).Returns("A");
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 3)).Returns("B");
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 4)).Returns("C");

            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual("B", result.Result);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void MatchShouldReturnIndexOfMatchingValVertical_MatchTypeExact()
        {
            var func = new Match();
            var args = FunctionsHelper.CreateArgs(3, "A1:A3", 0);
            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,2, 1)).Returns(3);
            A.CallTo(() => provider.GetCellValue(WorksheetName,3, 1)).Returns(5);
            A.CallTo(() => provider.GetDimensionEnd(A<string>.Ignored)).Returns(new ExcelCellAddress(100, 10));
            parsingContext.ExcelDataProvider = provider;
            var result = func.Execute(args, parsingContext);
            replacedert.AreEqual(2, result.Result);
        }

19 View Source File : AddressTranslatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            _excelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => _excelDataProvider.ExcelMaxRows).Returns(ExcelMaxRows);
            _addressTranslator = new AddressTranslator(_excelDataProvider);
        }

19 View Source File : CellReferenceProviderTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            _provider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => _provider.ExcelMaxRows).Returns(5000);
        }

19 View Source File : IndexToAddressTranslatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

private void SetupTranslator(int maxRows, ExcelReferenceType refType)
        {
            _excelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => _excelDataProvider.ExcelMaxRows).Returns(maxRows);
            _indexToAddressTranslator = new IndexToAddressTranslator(_excelDataProvider, refType);
        }

19 View Source File : RangeAddressFactoryTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            var provider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => provider.ExcelMaxRows).Returns(ExcelMaxRows);
            _factory = new RangeAddressFactory(provider);
        }

19 View Source File : RangeAddressTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            var provider = A.Fake<ExcelDataProvider>();
            _factory = new RangeAddressFactory(provider);
        }

19 View Source File : InformationFunctionsTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            _excelDataProvider = A.Fake<ExcelDataProvider>();
            _parser = new FormulaParser(_excelDataProvider);
        }

19 View Source File : LogicalFunctionsTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            var excelDataProvider = A.Fake<ExcelDataProvider>();
            _parser = new FormulaParser(excelDataProvider);
        }

19 View Source File : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Initialize()
        {
            _excelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => _excelDataProvider.GetDimensionEnd(A<string>.Ignored)).Returns(new ExcelCellAddress(10, 1));
            _parser = new FormulaParser(_excelDataProvider);
            _package = new ExcelPackage();
            _worksheet = _package.Workbook.Worksheets.Add("Test");
        }

19 View Source File : TokenFactoryTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            var context = ParsingContext.Create();
            var excelDataProvider = A.Fake<ExcelDataProvider>();
            _nameValueProvider = A.Fake<INameValueProvider>();
            _tokenFactory = new TokenFactory(context.Configuration.FunctionRepository, _nameValueProvider);
        }

19 View Source File : FormulaParserTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            var provider = A.Fake<ExcelDataProvider>();
            _parser = new FormulaParser(provider);

        }

19 View Source File : FormulaParserTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ParserShouldCallLexer()
        {
            var lexer = A.Fake<ILexer>();
            A.CallTo(() => lexer.Tokenize("ABC")).Returns(Enumerable.Empty<Token>());
            _parser.Configure(x => x.SetLexer(lexer));

            _parser.Parse("ABC");

            A.CallTo(() => lexer.Tokenize("ABC")).MustHaveHappened();
        }

19 View Source File : FormulaParserTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ParserShouldCallGraphBuilder()
        {
            var lexer = A.Fake<ILexer>();
            var tokens = new List<Token>();
            A.CallTo(() => lexer.Tokenize("ABC")).Returns(tokens);
            var graphBuilder = A.Fake<IExpressionGraphBuilder>();
            A.CallTo(() => graphBuilder.Build(tokens)).Returns(new ExGraph());

            _parser.Configure(config =>
                {
                    config
                        .SetLexer(lexer)
                        .SetGraphBuilder(graphBuilder);
                });

            _parser.Parse("ABC");

            A.CallTo(() => graphBuilder.Build(tokens)).MustHaveHappened();
        }

19 View Source File : FormulaParserTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ParserShouldCallCompiler()
        {
            var lexer = A.Fake<ILexer>();
            var tokens = new List<Token>();
            A.CallTo(() => lexer.Tokenize("ABC")).Returns(tokens);
            var expectedGraph = new ExGraph();
            expectedGraph.Add(new StringExpression("asdf"));
            var graphBuilder = A.Fake<IExpressionGraphBuilder>();
            A.CallTo(() => graphBuilder.Build(tokens)).Returns(expectedGraph);
            var compiler = A.Fake<IExpressionCompiler>();
            A.CallTo(() => compiler.Compile(expectedGraph.Expressions)).Returns(new CompileResult(0, DataType.Integer));

            _parser.Configure(config =>
            {
                config
                    .SetLexer(lexer)
                    .SetGraphBuilder(graphBuilder)
                    .SetExpresionCompiler(compiler);
            });

            _parser.Parse("ABC");

            A.CallTo(() => compiler.Compile(expectedGraph.Expressions)).MustHaveHappened();
        }

19 View Source File : ExcelAddressExpressionTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod, ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorShouldThrowIfParsingContextIsNull()
        {
            new ExcelAddressExpression("A1", A.Fake<ExcelDataProvider>(), null);
        }

19 View Source File : ExpressionFactoryTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            _parsingContext = ParsingContext.Create();
            var provider = A.Fake<ExcelDataProvider>();
            _factory = new ExpressionFactory(provider, _parsingContext);
        }

19 View Source File : ExpressionGraphBuilderTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestInitialize]
        public void Setup()
        {
            _excelDataProvider = A.Fake<ExcelDataProvider>();
            var parsingContext = ParsingContext.Create();
            _graphBuilder = new ExpressionGraphBuilder(_excelDataProvider, parsingContext);
        }

See More Examples