Update mcs/class/Commons.Xml.Relaxng/Commons.Xml.Relaxng/RelaxngPattern.cs
[mono.git] / mcs / class / System.Data.Linq / src / DbMetal / Test / EnglishWordsTest.cs
1 #region MIT license\r
2 // \r
3 // MIT license\r
4 //\r
5 // Copyright (c) 2007-2008 Jiri Moudry\r
6 // \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
13 // \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
16 // \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
23 // THE SOFTWARE.\r
24 // \r
25 #endregion\r
26 \r
27 using DbMetal.Language;\r
28 using System.Collections.Generic;\r
29 using NUnit.Framework;\r
30 \r
31 namespace DbLinqTest\r
32 {\r
33 \r
34 \r
35     /// <summary>\r
36     ///This is a test class for EnglishWordsTest and is intended\r
37     ///to contain all EnglishWordsTest Unit Tests\r
38     ///</summary>\r
39     [TestFixture]\r
40     public class EnglishWordsTest\r
41     {\r
42         public EnglishWordsTest()\r
43         {\r
44             englishWords = new EnglishWords();\r
45             englishWords.Load();\r
46         }\r
47 \r
48         public static void AssertAreIListEqual(IList<string> a, IList<string> b)\r
49         {\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
53         }\r
54 \r
55         public static void AssertAreEqual(IList<string> a, params string[] b)\r
56         {\r
57             AssertAreIListEqual(a, b);\r
58         }\r
59 \r
60         /*\r
61         hiredate\r
62         quantityperunit\r
63         unitsinstock\r
64         fkterrregion\r
65         fkprodcatg\r
66         */\r
67 \r
68         private EnglishWords englishWords;\r
69 \r
70         [Test]\r
71         public void GetWordsTest_HelloWorld()\r
72         {\r
73             var actual = englishWords.GetWords("helloworld");\r
74             AssertAreEqual(actual, "hello", "world");\r
75         }\r
76 \r
77         [Test]\r
78         public void GetWordsTest_HireDate()\r
79         {\r
80             var actual = englishWords.GetWords("hiredate");\r
81             AssertAreEqual(actual, "hire", "date");\r
82         }\r
83 \r
84         [Test]\r
85         public void GetWordsTest_QuantityPerUnit()\r
86         {\r
87             var actual = englishWords.GetWords("quantityperunit");\r
88             AssertAreEqual(actual, "quantity", "per", "unit");\r
89         }\r
90 \r
91         [Test]\r
92         public void GetWordsTest_UnitsInStock()\r
93         {\r
94             var actual = englishWords.GetWords("unitsinstock");\r
95             AssertAreEqual(actual, "units", "in", "stock");\r
96         }\r
97         // we can't rely on this test, since "terr" is not a word, so the algorithm returs "ft" "t" "err" "region"\r
98         //[Test]\r
99         //public void GetWords4Test()\r
100         //{\r
101         //    var actual = englishWords.GetWords("fkterrregion");\r
102         //    AssertAreEqual(actual, "fk", "terr", "region");\r
103         //}\r
104         [Test]\r
105         public void GetWordsTest_FkProdCatG()\r
106         {\r
107             var actual = englishWords.GetWords("fkprodcatg");\r
108             AssertAreEqual(actual, "fk", "prod", "cat", "g");\r
109         }\r
110 \r
111         [Test]\r
112         public void GetWordsTest_CatG()\r
113         {\r
114             var actual = englishWords.GetWords("catg");\r
115             AssertAreEqual(actual, "cat", "g");\r
116         }\r
117 \r
118         [Test]\r
119         public void GetWordsTest_CustomerId()\r
120         {\r
121             var actual = englishWords.GetWords("customerid");\r
122             AssertAreEqual(actual, "customer", "id");\r
123         }\r
124 \r
125         [Test]\r
126         public void GetWordsTest_SupplierId()\r
127         {\r
128             var actual = englishWords.GetWords("supplierid");\r
129             AssertAreEqual(actual, "supplier", "id");\r
130         }\r
131 \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
134         //[TestMethod]\r
135         //[Test]\r
136         //public void GetWordsTest_IntType()\r
137         //{\r
138         //    var actual = englishWords.GetWords("inttype");\r
139         //    AssertAreEqual(actual, "int", "type");\r
140         //}\r
141 \r
142         [Test]\r
143         public void GetWordsTest_AllIntType()\r
144         {\r
145             var actual = englishWords.GetWords("allinttype");\r
146             AssertAreEqual(actual, "all", "int", "type");\r
147         }\r
148 \r
149         [Test]\r
150         public void GetNoteTest_ToothPaste()\r
151         {\r
152             Assert.IsTrue(englishWords.GetNote(new[] { "toothpaste" }) > englishWords.GetNote(new[] { "tooth", "paste" }));\r
153         }\r
154 \r
155         [Test]\r
156         public void GetNoteTest_PerUnit()\r
157         {\r
158             Assert.IsTrue(englishWords.GetNote(new[] { "per", "unit" }) > englishWords.GetNote(new[] { "peru", "nit" }));\r
159         }\r
160 \r
161         [Test]\r
162         public void GetNoteTest_Hello()\r
163         {\r
164             Assert.IsTrue(englishWords.GetNote(new[] { "hello" }) > englishWords.GetNote(new[] { "h", "e", "l", "l", "o" }));\r
165         }\r
166     }\r
167 }\r