예제 #1
0
        public void op_MoveTo_LexiconNull_LexicalItem()
        {
            var obj  = new LexicalCollection(NormalityComparer.Ordinal);
            var item = new LexicalItem(NormalityComparer.Ordinal, "Example");

            Assert.Throws <ArgumentNullException>(() => obj.MoveTo(null, item));
        }
예제 #2
0
        public void op_MoveTo_LexiconSame_LexicalItem()
        {
            var obj  = new LexicalCollection(NormalityComparer.Ordinal);
            var item = new LexicalItem(NormalityComparer.Ordinal, "Example");

            Assert.Throws <InvalidOperationException>(() => obj.MoveTo(obj, item));
        }
예제 #3
0
        public void op_MoveTo_Lexicon_LexicalItemNull()
        {
            var obj         = new LexicalCollection(NormalityComparer.Ordinal);
            var destination = new LexicalCollection(NormalityComparer.Ordinal);

            Assert.Throws <ArgumentNullException>(() => obj.MoveTo(destination, null));
        }
예제 #4
0
        public void op_Match_stringEmpty()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "Example")
            };

            Assert.Null(obj.Match(string.Empty));
        }
예제 #5
0
        public void op_Add_LexicalItemNull()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            // ReSharper disable RedundantCast
            Assert.Throws <ArgumentNullException>(() => obj.Add(null as LexicalItem));

            // ReSharper restore RedundantCast
        }
예제 #6
0
        public void op_Contains_string_whenOrdinalIgnoreCaseComparer()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                "Example"
            };

            Assert.True(obj.Contains("EXAMPLE"));
        }
예제 #7
0
        public void op_Contains_string()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                "Example"
            };

            Assert.True(obj.Contains("Example"));
        }
예제 #8
0
        public void op_Match_stringNull()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "Example")
            };

            Assert.Throws <ArgumentNullException>(() => obj.Match(null));
        }
예제 #9
0
        public void op_Remove_IEnumerableLexicalItemsEmpty()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add("1").Synonyms.Add("One");

            obj.Remove(new LexicalCollection(NormalityComparer.Ordinal));

            Assert.Equal(1, obj.Count());
        }
예제 #10
0
        public void op_Remove_LexicalItem()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add("1").Synonyms.Add("One");

            obj.Remove(new LexicalItem(NormalityComparer.Ordinal, "1"));

            Assert.Equal(0, obj.Count());
        }
예제 #11
0
        public void op_Invoke_Func()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add(string.Concat("Foo", '\u00A0', "Bar")).Synonyms.Add(string.Concat("Left", '\u00A0', "Right"));

            obj.Invoke(x => x.NormalizeWhiteSpace());

            Assert.Equal("Foo Bar", obj.First().CanonicalForm);
            Assert.Equal("Left Right", obj.First().Synonyms.First());
        }
예제 #12
0
        public void op_MatchBeginning_string_whenContainsDoubleSpace()
        {
            const string expected = "Example";

            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                expected
            };

            Assert.Null(obj.MatchBeginning("a  z"));
        }
예제 #13
0
        public void indexer_string_getWhenSynonym()
        {
            const string expected = "Foo";
            var          obj      = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add(expected).Synonyms.Add("Bar");

            var actual = obj["Bar"].CanonicalForm;

            Assert.Same(expected, actual);
        }
예제 #14
0
        public void op_ToCanonicalForm_string_whenOrdinalIgnoreCaseComparer()
        {
            const string expected = "1";

            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase);

            obj.Add(expected).Synonyms.Add("One");

            var actual = obj.ToCanonicalForm("ONE");

            Assert.Equal(expected, actual);
        }
예제 #15
0
        public void op_Add_string_alreadyExistsAsSynonym()
        {
            const string expected = "foo";

            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add("bar").Synonyms.Add(expected);

            obj.Add(expected);

            Assert.Equal(1, obj.Count());
        }
예제 #16
0
        public void op_Add_string_alreadyExists()
        {
            const string expected = "Example";

            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                expected,
                expected
            };

            Assert.Equal(1, obj.Count());
        }
예제 #17
0
        public void op_Match_string()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "Example")
            };

            var expected = new LexicalMatch(obj.First());
            var actual   = obj.Match("EXAMPLE");

            Assert.Equal(expected, actual);
        }
예제 #18
0
        public void prop_CanonicalForms_get()
        {
            const string expected = "1";

            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add(expected).Synonyms.Add("One");

            var actual = obj.CanonicalForms.First();

            Assert.Equal(expected, actual);
        }
예제 #19
0
        public void indexer_string_get()
        {
            const string expected = "Example";

            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                expected
            };

            var actual = obj[expected].CanonicalForm;

            Assert.Same(expected, actual);
        }
예제 #20
0
        public void op_Add_string()
        {
            const string expected = "Example";

            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                expected
            };

            var actual = obj.First().CanonicalForm;

            Assert.Equal(expected, actual);
        }
예제 #21
0
        public void op_Add_LexicalItem()
        {
            const string expected = "Example";

            var obj = new LexicalCollection(NormalityComparer.Ordinal)
            {
                new LexicalItem(NormalityComparer.CurrentCulture, expected)
            };

            var actual = obj.First().CanonicalForm;

            Assert.Equal(expected, actual);
        }
예제 #22
0
        public void op_Remove_IEnumerableLexicalItemsSynonym()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            obj.Add("Foo").Synonyms.Add("One");

            var lexicon = new LexicalCollection(NormalityComparer.Ordinal);

            lexicon.Add("Bar").Synonyms.Add("One");

            obj.Remove(lexicon);

            Assert.Equal(0, obj.Count());
        }
예제 #23
0
        public void op_MatchBeginning_string()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "Example")
            };

            var expected = new LexicalMatch(obj.First())
            {
                Suffix = "test case"
            };
            var actual = obj.MatchBeginning("example test case");

            Assert.Equal(expected, actual);
        }
예제 #24
0
        public void op_MatchEnding_string()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "Example")
            };

            var expected = new LexicalMatch(obj.First())
            {
                Prefix = "This is an"
            };
            var actual = obj.MatchEnding("This is an example");

            Assert.Equal(expected, actual);
        }
예제 #25
0
        public void op_MoveTo_Lexicon_LexicalItem()
        {
            const string expected = "Example";

            var source = new LexicalCollection(NormalityComparer.Ordinal);
            var item   = source.Add(expected);

            var destination = new LexicalCollection(NormalityComparer.Ordinal);

            source.MoveTo(destination, item);

            Assert.Empty(source);
            var actual = destination.First().CanonicalForm;

            Assert.Equal(expected, actual);
        }
예제 #26
0
        public void op_MatchBeginning_string_whenShorterAndLonger()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "one"),
                new LexicalItem(NormalityComparer.Ordinal, "one two")
            };

            var expected = new LexicalMatch(obj.Last())
            {
                Suffix = "3"
            };
            var actual = obj.MatchBeginning("one two 3");

            Assert.Equal(expected, actual);
            Assert.Equal("3", actual.Suffix);
        }
예제 #27
0
        public void op_MatchEnding_string_whenShorterAndLonger()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "two"),
                new LexicalItem(NormalityComparer.Ordinal, "two three")
            };

            var expected = new LexicalMatch(obj.Last())
            {
                Prefix = "1"
            };
            var actual = obj.MatchEnding("1 two three");

            Assert.Equal(expected, actual);
            Assert.Equal("1", actual.Prefix);
        }
예제 #28
0
        public void op_MatchWithin_string_whenLongerAndShorter()
        {
            var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase)
            {
                new LexicalItem(NormalityComparer.Ordinal, "two three"),
                new LexicalItem(NormalityComparer.Ordinal, "three")
            };

            var expected = new LexicalMatch(obj.First())
            {
                Prefix = "1",
                Suffix = "4"
            };
            var actual = obj.MatchWithin("1 two three 4");

            Assert.Equal(expected, actual);
            Assert.Equal("1", actual.Prefix);
            Assert.Equal("4", actual.Suffix);
        }
예제 #29
0
        public virtual void MoveTo(LexicalCollection destination,
                                   LexicalItem item)
        {
            if (null == destination)
            {
                throw new ArgumentNullException("destination");
            }

            if (ReferenceEquals(this, destination))
            {
                throw new InvalidOperationException("The source and destination cannot be the same instance.");
            }

            if (null == item)
            {
                throw new ArgumentNullException("item");
            }

            Remove(new[] { item });
            destination.Add(item);
        }
예제 #30
0
        public void indexer_string_getWhenNotFound()
        {
            var obj = new LexicalCollection(NormalityComparer.Ordinal);

            Assert.Null(obj["Example"]);
        }