2222 * THE SOFTWARE.
2323 */
2424
25- using System ;
26- using System . CodeDom ;
2725using System . Diagnostics ;
2826using System . Diagnostics . CodeAnalysis ;
29- using System . Globalization ;
3027using System . IO ;
3128using System . Reflection ;
3229using System . Threading . Tasks ;
3330using F23 . StringSimilarity . Tests . TestUtil ;
3431using Xunit ;
35- using Xunit . Abstractions ;
3632
3733namespace F23 . StringSimilarity . Tests
3834{
3935 [ SuppressMessage ( "ReSharper" , "ArgumentsStyleLiteral" ) ]
4036 [ SuppressMessage ( "ReSharper" , "ArgumentsStyleNamedExpression" ) ]
4137 public class CosineTest
4238 {
43- private readonly ITestOutputHelper _testOutputHelper ;
44-
45- public CosineTest ( ITestOutputHelper testOutputHelper )
46- {
47- _testOutputHelper = testOutputHelper ;
48- }
49-
5039 [ Fact ]
5140 public void TestSimilarity ( )
5241 {
@@ -55,8 +44,8 @@ public void TestSimilarity()
5544 var result = instance . Similarity ( "ABC" , "ABCE" ) ;
5645
5746 Assert . Equal (
58- expected : 0.71 ,
59- actual : result ,
47+ expected : 0.71 ,
48+ actual : result ,
6049 precision : 2 // 0.01
6150 ) ;
6251
@@ -71,8 +60,8 @@ public void TestSmallString()
7160 var result = instance . Similarity ( "AB" , "ABCE" ) ;
7261
7362 Assert . Equal (
74- expected : 0.0 ,
75- actual : result ,
63+ expected : 0.0 ,
64+ actual : result ,
7665 precision : 5 //0.00001
7766 ) ;
7867 }
@@ -89,7 +78,7 @@ public async Task TestLargeString()
8978 var result = instance . Similarity ( string1 , string2 ) ;
9079
9180 Assert . Equal (
92- expected : 0.8115 ,
81+ expected : 0.8115 ,
9382 actual : result ,
9483 precision : 3 //0.001
9584 ) ;
@@ -144,19 +133,34 @@ public void DocumentationExampleTest()
144133 Assert . Equal ( 0.516185 , cosine . Similarity ( profile1 , profile2 ) , 6 ) ;
145134 }
146135
136+ /// <summary>
137+ /// StringSimilarity.NET specific. Ensures that GetProfile is public.
138+ /// </summary>
139+ /// <remarks>
140+ /// https://github.com/feature23/StringSimilarity.NET/issues/21
141+ /// </remarks>
142+ [ Fact ]
143+ public void GetProfile_IsPublic ( )
144+ {
145+ var cosine = new Cosine ( k : 2 ) ;
146+ var profile = cosine . GetProfile ( "test string" ) ;
147+
148+ Assert . NotNull ( profile ) ;
149+ }
150+
147151 private static async Task < string > ReadResourceFileAsync ( string file )
148152 {
149153 var assembly = Assembly . GetExecutingAssembly ( ) ;
150154 var resourceName = $ "{ typeof ( CosineTest ) . Namespace } .{ file } ";
151155
152- using ( var stream = assembly . GetManifestResourceStream ( resourceName ) )
153- {
154- Debug . Assert ( stream != null , "stream != null" ) ;
155- using ( var reader = new StreamReader ( stream ) )
156- {
157- return await reader . ReadToEndAsync ( ) ;
158- }
159- }
156+ // ReSharper disable once UseAwaitUsing - not supported on netstandard2.0
157+ using var stream = assembly . GetManifestResourceStream ( resourceName ) ;
158+
159+ Debug . Assert ( stream != null , " stream != null" ) ;
160+
161+ using var reader = new StreamReader ( stream ) ;
162+
163+ return await reader . ReadToEndAsync ( ) ;
160164 }
161165 }
162166}
0 commit comments