csharp/Appdynamics/AppDynamics.DEXTER/Appdynamics-AppDynamics.DEXTER-63a3338/EPPlus/EPPlus-master/EPPlus-master/EPPlusTest/FormulaParsing/Excel/Functions/Database/RowMatcherTests.cs

RowMatcherTests.cs
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OfficeOpenXml.FormulaParsing;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
using FakeItEasy;

namespace EPPlusTest.FormulaParsing.Excel.Functions.Database
{
    [TestClast]
    public clast RowMatcherTests
    {
        private ExcelDatabaseCriteria GetCriteria(Dictionary items)
        {
            var provider = A.Fake();
            var criteria = A.Fake();// (provider, string.Empty);

            A.CallTo(() => criteria.Items).Returns(items);
            return criteria;
        }
        [TestMethod]
        public void IsMatchShouldReturnTrueIfCriteriasMatch()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = 1;
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit1")] = 1;
            crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;

            var matcher = new RowMatcher();

            var criteria = GetCriteria(crit);

            astert.IsTrue(matcher.IsMatch(data, criteria));
        }

        [TestMethod]
        public void IsMatchShouldReturnFalseIfCriteriasDoesNotMatch()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = 1;
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit1")] = 1;
            crit[new ExcelDatabaseCriteriaField("Crit3")] = 4;

            var matcher = new RowMatcher();

            var criteria = GetCriteria(crit);

            astert.IsFalse(matcher.IsMatch(data, criteria));
        }

        [TestMethod]
        public void IsMatchShouldMatchStrings1()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = "1";
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit1")] = "1";
            crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;

            var matcher = new RowMatcher();

            var criteria = GetCriteria(crit);

            astert.IsTrue(matcher.IsMatch(data, criteria));
        }

        [TestMethod]
        public void IsMatchShouldMatchStrings2()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = "2";
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit1")] = "1";
            crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;

            var matcher = new RowMatcher();

            var criteria = GetCriteria(crit);

            astert.IsFalse(matcher.IsMatch(data, criteria));
        }

        [TestMethod]
        public void IsMatchShouldMatchWildcardStrings()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = "test";
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit1")] = "t*t";
            crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;

            var matcher = new RowMatcher();

            var criteria = GetCriteria(crit);

            astert.IsTrue(matcher.IsMatch(data, criteria));
        }

        [TestMethod]
        public void IsMatchShouldMatchNumericExpression()
        {
            var data = new ExcelDatabaseRow();
            data["Crit1"] = "test";
            data["Crit2"] = 2;
            data["Crit3"] = 3;

            var crit = new Dictionary();
            crit[new ExcelDatabaseCriteriaField("Crit2")] = "