5 // Copyright (c) 2007-2008 Jiri Moudry
\r
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
\r
8 // of this software and associated documentation files (the "Software"), to deal
\r
9 // in the Software without restriction, including without limitation the rights
\r
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
11 // copies of the Software, and to permit persons to whom the Software is
\r
12 // furnished to do so, subject to the following conditions:
\r
14 // The above copyright notice and this permission notice shall be included in
\r
15 // all copies or substantial portions of the Software.
\r
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
27 using DbMetal.Language;
\r
28 using System.Collections.Generic;
\r
29 using NUnit.Framework;
\r
31 namespace DbLinqTest
\r
36 ///This is a test class for EnglishWordsTest and is intended
\r
37 ///to contain all EnglishWordsTest Unit Tests
\r
40 public class EnglishWordsTest
\r
42 public EnglishWordsTest()
\r
44 englishWords = new EnglishWords();
\r
45 englishWords.Load();
\r
48 public static void AssertAreIListEqual(IList<string> a, IList<string> b)
\r
50 Assert.AreEqual(b.Count, a.Count);
\r
51 for (int index = 0; index < a.Count; index++)
\r
52 Assert.AreEqual(b[index], a[index]);
\r
55 public static void AssertAreEqual(IList<string> a, params string[] b)
\r
57 AssertAreIListEqual(a, b);
\r
68 private EnglishWords englishWords;
\r
71 public void GetWordsTest_HelloWorld()
\r
73 var actual = englishWords.GetWords("helloworld");
\r
74 AssertAreEqual(actual, "hello", "world");
\r
78 public void GetWordsTest_HireDate()
\r
80 var actual = englishWords.GetWords("hiredate");
\r
81 AssertAreEqual(actual, "hire", "date");
\r
85 public void GetWordsTest_QuantityPerUnit()
\r
87 var actual = englishWords.GetWords("quantityperunit");
\r
88 AssertAreEqual(actual, "quantity", "per", "unit");
\r
92 public void GetWordsTest_UnitsInStock()
\r
94 var actual = englishWords.GetWords("unitsinstock");
\r
95 AssertAreEqual(actual, "units", "in", "stock");
\r
97 // we can't rely on this test, since "terr" is not a word, so the algorithm returs "ft" "t" "err" "region"
\r
99 //public void GetWords4Test()
\r
101 // var actual = englishWords.GetWords("fkterrregion");
\r
102 // AssertAreEqual(actual, "fk", "terr", "region");
\r
105 public void GetWordsTest_FkProdCatG()
\r
107 var actual = englishWords.GetWords("fkprodcatg");
\r
108 AssertAreEqual(actual, "fk", "prod", "cat", "g");
\r
112 public void GetWordsTest_CatG()
\r
114 var actual = englishWords.GetWords("catg");
\r
115 AssertAreEqual(actual, "cat", "g");
\r
119 public void GetWordsTest_CustomerId()
\r
121 var actual = englishWords.GetWords("customerid");
\r
122 AssertAreEqual(actual, "customer", "id");
\r
126 public void GetWordsTest_SupplierId()
\r
128 var actual = englishWords.GetWords("supplierid");
\r
129 AssertAreEqual(actual, "supplier", "id");
\r
132 // picrap: this one's failing, and I think we're at the limits of words recognition
\r
133 // (at least at the limits of what I'm able to do)
\r
136 //public void GetWordsTest_IntType()
\r
138 // var actual = englishWords.GetWords("inttype");
\r
139 // AssertAreEqual(actual, "int", "type");
\r
143 public void GetWordsTest_AllIntType()
\r
145 var actual = englishWords.GetWords("allinttype");
\r
146 AssertAreEqual(actual, "all", "int", "type");
\r
150 public void GetNoteTest_ToothPaste()
\r
152 Assert.IsTrue(englishWords.GetNote(new[] { "toothpaste" }) > englishWords.GetNote(new[] { "tooth", "paste" }));
\r
156 public void GetNoteTest_PerUnit()
\r
158 Assert.IsTrue(englishWords.GetNote(new[] { "per", "unit" }) > englishWords.GetNote(new[] { "peru", "nit" }));
\r
162 public void GetNoteTest_Hello()
\r
164 Assert.IsTrue(englishWords.GetNote(new[] { "hello" }) > englishWords.GetNote(new[] { "h", "e", "l", "l", "o" }));
\r