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)); }
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)); }
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)); }
public void op_Match_stringEmpty() { var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase) { new LexicalItem(NormalityComparer.Ordinal, "Example") }; Assert.Null(obj.Match(string.Empty)); }
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 }
public void op_Contains_string_whenOrdinalIgnoreCaseComparer() { var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase) { "Example" }; Assert.True(obj.Contains("EXAMPLE")); }
public void op_Contains_string() { var obj = new LexicalCollection(NormalityComparer.Ordinal) { "Example" }; Assert.True(obj.Contains("Example")); }
public void op_Match_stringNull() { var obj = new LexicalCollection(NormalityComparer.OrdinalIgnoreCase) { new LexicalItem(NormalityComparer.Ordinal, "Example") }; Assert.Throws <ArgumentNullException>(() => obj.Match(null)); }
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()); }
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()); }
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()); }
public void op_MatchBeginning_string_whenContainsDoubleSpace() { const string expected = "Example"; var obj = new LexicalCollection(NormalityComparer.Ordinal) { expected }; Assert.Null(obj.MatchBeginning("a z")); }
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); }
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); }
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()); }
public void op_Add_string_alreadyExists() { const string expected = "Example"; var obj = new LexicalCollection(NormalityComparer.Ordinal) { expected, expected }; Assert.Equal(1, obj.Count()); }
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); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void indexer_string_getWhenNotFound() { var obj = new LexicalCollection(NormalityComparer.Ordinal); Assert.Null(obj["Example"]); }