-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove IEnumerable<string> ctor from SynonynMap (#11394)
* Remove IEnumerable<string> ctor from SynonynMap Fixes #10725 * Used shared index to reduce resource utilization * Updated APIs and CHANGELOG
- Loading branch information
Showing
10 changed files
with
599 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 6 additions & 27 deletions
33
sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.Serialization.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Azure.Search.Documents.Models; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Search.Documents.Tests.Models | ||
{ | ||
public class SynonymMapTests | ||
{ | ||
[Test] | ||
public void StringConstructorTests() | ||
{ | ||
ArgumentException ex = Assert.Throws<ArgumentNullException>(() => new SynonymMap(null, (string)null)); | ||
Assert.AreEqual("name", ex.ParamName); | ||
|
||
ex = Assert.Throws<ArgumentException>(() => new SynonymMap(string.Empty, (string)null)); | ||
Assert.AreEqual("name", ex.ParamName); | ||
|
||
ex = Assert.Throws<ArgumentNullException>(() => new SynonymMap("test", (string)null)); | ||
Assert.AreEqual("synonyms", ex.ParamName); | ||
|
||
ex = Assert.Throws<ArgumentException>(() => new SynonymMap("test", string.Empty)); | ||
Assert.AreEqual("synonyms", ex.ParamName); | ||
} | ||
|
||
[Test] | ||
public void TextReaderConstructorTests() | ||
{ | ||
ArgumentException ex = Assert.Throws<ArgumentNullException>(() => new SynonymMap(null, (TextReader)null)); | ||
Assert.AreEqual("name", ex.ParamName); | ||
|
||
ex = Assert.Throws<ArgumentException>(() => new SynonymMap(string.Empty, (TextReader)null)); | ||
Assert.AreEqual("name", ex.ParamName); | ||
|
||
ex = Assert.Throws<ArgumentNullException>(() => new SynonymMap("test", (TextReader)null)); | ||
Assert.AreEqual("reader", ex.ParamName); | ||
} | ||
|
||
[Test] | ||
public void SynonymsFromTextReader() | ||
{ | ||
using StringReader reader = new StringReader("ms,msft=>Microsoft\naz=>Azure"); | ||
|
||
SynonymMap map = new SynonymMap("test", reader); | ||
Assert.AreEqual("ms,msft=>Microsoft\naz=>Azure", map.Synonyms); | ||
} | ||
|
||
[Test] | ||
public void CanonicalizesNullPropertyNames() | ||
{ | ||
Assert.IsNull(SynonymMap.CanonicalizePropertyNames(null)); | ||
} | ||
|
||
[Test] | ||
public void CanonicalizesPropertyNames() | ||
{ | ||
IEnumerable<string> actual = SynonymMap.CanonicalizePropertyNames(new[] | ||
{ | ||
nameof(SynonymMap.Name), | ||
nameof(SynonymMap.Format), | ||
nameof(SynonymMap.Synonyms), | ||
nameof(SynonymMap.EncryptionKey), | ||
nameof(SynonymMap.ETag), | ||
"Other", | ||
}); | ||
|
||
IEnumerable<string> expected = new[] | ||
{ | ||
"name", | ||
"format", | ||
"synonyms", | ||
"encryptionKey", | ||
"@odata.etag", | ||
"Other", | ||
}; | ||
|
||
CollectionAssert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.