コード例 #1
0
        public void GivenEmptyQuery_ExpectEmptyResult()
        {
            var matcher = new EnContactMatcher <TestContact>(this.Targets, this.ContactFieldsExtrator);
            var results = matcher.Find(string.Empty);

            Assert.AreEqual(0, results.Count);
        }
コード例 #2
0
 public void GivenNullQuery_ExpectException()
 {
     Assert.ThrowsException <ArgumentNullException>(() =>
     {
         var matcher = new EnContactMatcher <TestContact>(this.Targets, this.ContactFieldsExtrator);
         matcher.Find(null);
     });
 }
コード例 #3
0
        public void GivenExactMatch_ExpectPositiveMatch()
        {
            var matcher = new EnContactMatcher <TestContact>(this.Targets, this.ContactFieldsExtrator);
            var results = matcher.Find("Andrew Smith");

            Assert.AreEqual(1, results.Count);
            var expected = new TestContact()
            {
                FirstName = "Andrew",
                LastName  = "Smith",
                Id        = "1234567"
            };

            Assert.AreEqual(expected, results[0]);
        }
コード例 #4
0
        public void GivenSimilarPhoneticWeight_ExpectPositiveMatch()
        {
            var matcher = new EnContactMatcher <TestContact>(this.Targets, this.ContactFieldsExtrator);
            var results = matcher.Find("andru");

            Assert.AreEqual(2, results.Count);
            var expected = new TestContact()
            {
                FirstName = "Andrew",
                LastName  = string.Empty
            };

            Assert.IsTrue(results.Contains(expected));
            expected = new TestContact()
            {
                FirstName = "Andrew",
                LastName  = "Smith",
                Id        = "1234567"
            };
            Assert.IsTrue(results.Contains(expected));
        }
コード例 #5
0
        public void GivenDuplicateNames_ExpectPositiveMatch()
        {
            var matcher = new EnContactMatcher <TestContact>(this.Targets, this.ContactFieldsExtrator);
            var results = matcher.Find("john");

            Assert.AreEqual(2, results.Count);
            var expected = new TestContact()
            {
                FirstName = "John",
                LastName  = "B",
                Id        = "7654321"
            };

            Assert.IsTrue(results.Contains(expected));
            expected = new TestContact()
            {
                FirstName = "John",
                LastName  = "C",
                Id        = "2222222"
            };
            Assert.IsTrue(results.Contains(expected));
        }