FakeItEasy.A.CallTo(object, FakeItEasy.EventAction)

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

525 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 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 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 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 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 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 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 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 : 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 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 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 : 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 : IndexToAddressTranslatorTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ShouldTranslateToEntireColumnWhenRowIsEqualToMaxRows()
        {
            A.CallTo(() => _excelDataProvider.ExcelMaxRows).Returns(123456);
            var result = _indexToAddressTranslator.ToAddress(1, 123456);
            replacedert.AreEqual("A", result);
        }

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 : 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 : RefAndLookupTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void HLookupShouldReturnClosestValueBelowIfLastArgIsTrue()
        {
            var lookupAddress = "A1:B2";
            A.CallTo(() => _excelDataProvider.GetDimensionEnd(A<string>.Ignored)).Returns(new ExcelCellAddress(5, 5));
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 1)).Returns(3);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 2)).Returns(5);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,2, 1)).Returns(1);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,2, 2)).Returns(2);
            var result = _parser.Parse("HLOOKUP(4, " + lookupAddress + ", 2, true)");
            replacedert.AreEqual(1, result);
        }

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

[TestMethod]
        public void LookupShouldReturnMatchingValue()
        {
            var lookupAddress = "A1:B2";
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 1)).Returns(3);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 2)).Returns(5);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,2, 1)).Returns(4);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,2, 2)).Returns(1);
            var result = _parser.Parse("LOOKUP(4, " + lookupAddress + ")");
            replacedert.AreEqual(1, result);
        }

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

[TestMethod]
        public void MatchShouldReturnIndexOfMatchingValue()
        {
            var lookupAddress = "A1:A2";
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 1)).Returns(3);
            A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName,1, 2)).Returns(5);
            var result = _parser.Parse("MATCH(3, " + lookupAddress + ")");
            replacedert.AreEqual(1, result);
        }

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

[TestMethod]
        public void RowsShouldReturnNbrOfRows()
        {
            A.CallTo(() => _excelDataProvider.GetRangeFormula("", 4, 1)).Returns("Rows(A5:B7)");
            var result = _parser.ParseAt("A4");
            replacedert.AreEqual(3, result);
        }

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

[TestMethod]
        public void CreateShouldCreateNamedValueAsExcelAddressToken()
        {
            var input = "NamedValue";
            A.CallTo(() => _nameValueProvider.IsNamedValue("NamedValue","")).Returns(true);
            A.CallTo(() => _nameValueProvider.IsNamedValue("NamedValue", null)).Returns(true);
            var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
            replacedert.AreEqual(TokenType.NameValue, token.TokenType);
            replacedert.AreEqual("NamedValue", token.Value);
        }

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 : FormulaParserTests.cs
License : Apache License 2.0
Project Creator : Appdynamics

[TestMethod]
        public void ParseAtShouldCallExcelDataProvider()
        {
            var excelDataProvider = A.Fake<ExcelDataProvider>();
            A.CallTo(() => excelDataProvider.GetRangeFormula(string.Empty, 1, 1)).Returns("Sum(1,2)");
            var parser = new FormulaParser(excelDataProvider);
            var result = parser.ParseAt("A1");
            replacedert.AreEqual(3d, result);
        }

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

[TestMethod]
        public void RowShouldReturnRowNumber()
        {
            A.CallTo(() => _excelDataProvider.GetRangeFormula("", 4, 1)).Returns("Row()");
            var result = _parser.ParseAt("A4");
            replacedert.AreEqual(4, result);
        }

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

[TestMethod]
        public void ColumnShouldReturnRowNumber()
        {
            A.CallTo(() => _excelDataProvider.GetRangeFormula("", 4, 2)).Returns("Column()");
            var result = _parser.ParseAt("B4");
            replacedert.AreEqual(2, result);
        }

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

[TestMethod]
        public void ColumnsShouldReturnNbrOfCols()
        {
            A.CallTo(() => _excelDataProvider.GetRangeFormula("", 4, 1)).Returns("Columns(A5:B7)");
            var result = _parser.ParseAt("A4");
            replacedert.AreEqual(2, result);
        }

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

[TestMethod]
        public void AddressShouldReturnCorrectResult()
        {
            A.CallTo(() => _excelDataProvider.ExcelMaxRows).Returns(12345);
            var result = _parser.Parse("Address(1, 1)");
            replacedert.AreEqual("$A$1", result);
        }

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

[TestMethod]
        public void TextShouldConcatenateWithNextExpression()
        {
            A.CallTo(() =>_provider.GetFormat(23.5, "$0.00")).Returns("$23.50");
            var result = _parser.Parse("TEXT(23.5,\"$0.00\") & \" per hour\"");
            replacedert.AreEqual("$23.50 per hour", result);
        }

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

[TestMethod]
        public void LifetimeEventHandlerShouldBeCalled()
        {
            using (var scope = _parsingScopes.NewScope(RangeAddress.Empty))
            { }
            A.CallTo(() => _lifeTimeEventHandler.ParsingCompleted()).MustHaveHappened();
        }

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

[TestMethod]
        public void ScopeShouldCallKillScopeOnDispose()
        {
            var scope = new ParsingScope(_parsingScopes, _factory.Create("A1"));
            ((IDisposable)scope).Dispose();
           A.CallTo(() => _parsingScopes.KillScope(scope)).MustHaveHappened();
        }

19 View Source File : Asserting.cs
License : MIT License
Project Creator : DynamicsValue

public void replacederting_on_calls()
        {
            var factory = A.Fake<IWidgetFactory>();

            // This would throw an exception since no call has been made.
            A.CallTo(() => factory.Create()).MustHaveHappened();
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.AtLeast.Twice);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.AtLeast.Times(10));

            // This on the other hand would not throw.
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Never);

            // The number of times the call has been made can be restricted so that it must have happened
            // exactly the number of times specified
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Exactly.Times(4));

            // Then number of times can be specified so that it must not have happened more
            // than the specified number of times.
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.NoMoreThan.Twice);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.NoMoreThan.Times(5));
        }

See More Examples