-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathrosette_apiUnitTests.cs
More file actions
executable file
·1696 lines (1481 loc) · 88.6 KB
/
rosette_apiUnitTests.cs
File metadata and controls
executable file
·1696 lines (1481 loc) · 88.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using NUnit.Framework;
using rosette_api;
using RichardSzalay.MockHttp;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace rosette_apiUnitTests {
/// <summary>
/// Provides a concurrency test, non-unit. Keep commented out for release.
/// </summary>
[TestFixture]
public class ConcurrencyTest {
private static int threads = 3;
private static int calls = 5;
private static int loops = 1;
//[Test]
public void TestConcurrency() {
// To use the C# API, you must provide an API key
string apikey = Environment.GetEnvironmentVariable("API_KEY");
string alturl = string.Empty;
// Block on the test, otherwise the threads will exit before completion when main exits
while (loops-- > 0) {
StartTest(apikey, alturl).GetAwaiter().GetResult();
}
}
private static async Task StartTest(string apikey, string alturl) {
var tasks = new List<Task>();
CAPI api = string.IsNullOrEmpty(alturl) ? new CAPI(apikey) : new CAPI(apikey, alturl);
foreach (int task in Enumerable.Range(0, threads)) {
Console.WriteLine("Starting task {0}", task);
tasks.Add(Task.Factory.StartNew(() => runLookup(task, api)));
}
await Task.WhenAll(tasks);
Console.WriteLine("Test complete");
}
private static Task runLookup(int taskId, CAPI api) {
string entities_text_data = @"Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
//string contentUri = "http://www.foxsports.com/olympics/story/chad-le-clos-showed-why-you-never-talk-trash-to-michael-phelps-080916";
foreach (int call in Enumerable.Range(0, calls)) {
Console.WriteLine("Task ID: {0} call {1}", taskId, call);
try {
var result = api.Entity(content: entities_text_data);
Console.WriteLine("Concurrency: {0},Rresult: {1}", api.Concurrency, result);
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
return Task.FromResult(0);
}
}
[TestFixture]
public class RosetteResponseTests {
private string _testHeaderKey;
private string _testHeaderValue;
private string _testJson;
private int _testItemCount;
[SetUp]
public void Init() {
_testHeaderKey = "X-RosetteAPI-RequestId";
_testHeaderValue = "123456789";
_testJson = @"{ ""item1"":""value1"", ""item2"":""value2""}";
_testItemCount = 2;
}
[Test]
public void RosetteResponse_HeaderTest() {
HttpResponseMessage message = new HttpResponseMessage {
StatusCode = (HttpStatusCode)200,
ReasonPhrase = "OK",
Content = new StringContent(_testJson)
};
message.Headers.Add(_testHeaderKey, _testHeaderValue);
RosetteResponse rr = new RosetteResponse(message);
Assert.AreEqual(_testHeaderValue, rr.Headers[_testHeaderKey], "RosetteResponse: header mismatch");
}
[Test]
public void RosetteResponse_ContentTest() {
HttpResponseMessage message = new HttpResponseMessage {
StatusCode = (HttpStatusCode)200,
ReasonPhrase = "OK",
Content = new StringContent(_testJson)
};
message.Headers.Add(_testHeaderKey, _testHeaderValue);
RosetteResponse rr = new RosetteResponse(message);
# pragma warning disable 618
Assert.AreEqual(_testItemCount, rr.Content.Count, "RosetteResponse: header mismatch");
# pragma warning restore 618
}
[Test]
public void RosetteResponse_ContentAsJsonTest() {
HttpResponseMessage message = new HttpResponseMessage {
StatusCode = (HttpStatusCode)200,
ReasonPhrase = "OK",
Content = new StringContent(_testJson)
};
message.Headers.Add(_testHeaderKey, _testHeaderValue);
RosetteResponse rr = new RosetteResponse(message);
Assert.AreEqual(_testJson, rr.ContentAsJson, "RosetteResponse: json mismatch");
}
[Test]
public void RosetteResponse_ExceptionTest() {
HttpResponseMessage message = new HttpResponseMessage {
StatusCode = (HttpStatusCode)404,
ReasonPhrase = "Not Found",
Content = new StringContent(_testJson)
};
message.Headers.Add(_testHeaderKey, _testHeaderValue);
try {
new RosetteResponse(message);
Assert.Fail("Exception should have been thrown");
}
catch (RosetteException ex) {
Assert.AreEqual(404, ex.Code, "RosetteResponse: Exception mismatch");
}
}
}
[TestFixture]
public class RosetteExtensionsTests {
[Test]
public void MorphologyEndpointTest() {
string expected = "han-readings";
Assert.AreEqual(expected, RosetteExtensions.MorphologyEndpoint(MorphologyFeature.hanReadings), "Morphology endpoint mismatch");
}
}
[TestFixture]
public class Rosette_errorTests : IDisposable {
bool disposed = false;
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (disposed) {
return;
}
if (disposing) {
_mockHttp.Dispose();
}
disposed = true;
}
private MockHttpMessageHandler _mockHttp;
private CAPI _rosetteApi;
private string _testUrl = @"https://api.rosette.com/rest/v1/";
[OneTimeSetUp]
public void Init() {
_mockHttp = new MockHttpMessageHandler();
var client = new HttpClient(_mockHttp);
string jsonResponse = string.Format("{{'response': 'OK', 'version': '{0}'}}", CAPI.Version);
_mockHttp.When(_testUrl + "info")
.WithQueryString(string.Format("clientVersion={0}", CAPI.Version))
.Respond("applciation/json", jsonResponse);
_rosetteApi = new CAPI("userkey", null, 1, client);
}
[OneTimeTearDown]
public void Cleanup() {
}
[Test]
public void Error409_Test() {
try {
_mockHttp.When(_testUrl + "entities").Respond(HttpStatusCode.Conflict);
_rosetteApi.Entity("content");
Assert.Fail("Exception not thrown");
}
catch (RosetteException ex) {
Console.WriteLine("Error code: " + ex.Code);
Assert.AreEqual(ex.Code, 409);
return;
}
catch (Exception) {
Assert.Fail("RosetteException not thrown");
return;
}
}
}
[TestFixture]
public class Rosette_classTests {
[Test]
public void NameClassTest() {
Name name = new Name("text", "language", "script", "entityType");
Assert.AreEqual("text", name.text, "Name does not match");
Assert.AreEqual("language", name.language, "Language does not match");
Assert.AreEqual("script", name.script, "Script does not match");
Assert.AreEqual("entityType", name.entityType, "EntityType does not match");
}
[Test]
public void RosetteFileClassTest() {
string tmpFile = Path.GetTempFileName();
StreamWriter sw = File.AppendText(tmpFile);
sw.WriteLine("Rosette API Unit Test");
sw.Flush();
sw.Close();
RosetteFile f = new RosetteFile(tmpFile, "application/octet-stream", null);
Assert.IsNotNull(f.Filename, "Filename is null");
Assert.AreEqual(tmpFile, f.Filename, "Filename does not match");
Assert.AreEqual("application/octet-stream", f.ContentType, "ContentType does not match");
Assert.IsNull(f.Options, "Options does not match");
byte[] b = f.getFileData();
Assert.IsTrue(b.Count() > 0, "File is empty");
string content = f.getFileDataString();
Assert.IsTrue(content.Length > 0, "File is empty");
MultipartContent multiPart = f.AsMultipart();
Assert.IsTrue(multiPart.Headers.Count() > 0, "Multipart not populated");
f.Dispose();
if (File.Exists(tmpFile)) {
File.Delete(tmpFile);
}
}
[Test]
public void RosetteExceptionClassTest() {
RosetteException ex = new RosetteException("message", 1, "requestID", "file", "line");
Assert.AreEqual("message", ex.Message, "Message does not match");
Assert.AreEqual(1, ex.Code, "Code does not match");
Assert.AreEqual("requestID", ex.RequestID, "RequestID does not match");
Assert.AreEqual("file", ex.File, "File does not match");
Assert.AreEqual("line", ex.Line, "Line does not match");
}
}
[TestFixture]
public class Rosette_apiUnitTests : IDisposable {
bool disposed = false;
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (disposed) {
return;
}
if (disposing) {
_mockHttp.Dispose();
}
disposed = true;
}
/// <summary>Compress
/// <para>
/// Takes in byte data and compresses it using gzip.
/// Source: http://www.dotnetperls.com/compress
/// </para>
/// </summary>
/// <param name="raw">(byte[]): Raw data to be compressed</param>
/// <returns>(byte[]): Compressed data</returns>
public static byte[] Compress(byte[] raw) {
MemoryStream memory = new MemoryStream();
using (GZipStream gzip = new GZipStream(memory, CompressionMode.Compress, true)) {
gzip.Write(raw, 0, raw.Length);
}
return memory.ToArray();
}
/// <summary>Decompress
/// <para>Method to decompress GZIP files
/// Source: http://www.dotnetperls.com/decompress
/// </para>
/// </summary>
/// <param name="gzip">(byte[]): Data in byte form to decompress</param>
/// <returns>(byte[]) Decompressed data</returns>
private static byte[] Decompress(byte[] gzip) {
// Create a GZIP stream with decompression mode.
// ... Then create a buffer and write into while reading from the GZIP stream.
using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress)) {
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream memory = new MemoryStream()) {
int count = 0;
do {
count = stream.Read(buffer, 0, size);
if (count > 0) {
memory.Write(buffer, 0, count);
}
}
while (count > 0);
return memory.ToArray();
}
}
}
private MockHttpMessageHandler _mockHttp;
private CAPI _rosetteApi;
private string _testUrl = @"https://api.rosette.com/rest/v1/";
private string _tmpFile = null;
[OneTimeSetUp]
public void Init() {
// Create a temporary file for use with file testing
_tmpFile = Path.GetTempFileName();
StreamWriter sw = File.AppendText(_tmpFile);
sw.WriteLine("Rosette API Unit Test. This file is used for testing file operations.");
sw.Flush();
sw.Close();
_mockHttp = new MockHttpMessageHandler();
var client = new HttpClient(_mockHttp);
string jsonResponse = string.Format("{{'response': 'OK', 'version': '{0}'}}", CAPI.Version);
_mockHttp.When(_testUrl + "info")
.WithQueryString(string.Format("clientVersion={0}", CAPI.Version))
.Respond("applciation/json", jsonResponse);
_rosetteApi = new CAPI("userkey", null, 1, client);
}
[OneTimeTearDown]
public void Cleanup() {
if (File.Exists(_tmpFile)) {
File.Delete(_tmpFile);
}
_mockHttp.Clear();
}
//------------------------- User-Agent Test ----------------------------------------
[Test]
public void UserAgentTest() {
string uaString = string.Format("RosetteAPICsharp/{0}/{1}", CAPI.Version, Environment.Version.ToString());
Assert.AreEqual(uaString, _rosetteApi.UserAgent);
}
//------------------------- Simple Options Tests ----------------------------------------
[Test]
public void OptionsTest() {
KeyValuePair<string, string> expected = new KeyValuePair<string, string>("test", "testValue");
_rosetteApi.SetOption(expected.Key, expected.Value);
Assert.AreEqual(expected.Value, _rosetteApi.GetOption(expected.Key));
}
[Test]
public void ClearOptionsTest() {
_rosetteApi.SetOption("option1", "value1");
_rosetteApi.SetOption("option2", "value2");
_rosetteApi.ClearOptions();
Assert.IsNull(_rosetteApi.GetOption("option1"));
}
//------------------------- Simple Custom Header Tests ----------------------------------------
[Test]
public void CustomHeadersTest() {
KeyValuePair<string, string> expected = new KeyValuePair<string, string>("X-RosetteAPI-Test", "testValue");
_rosetteApi.SetCustomHeaders(expected.Key, expected.Value);
Assert.AreEqual(expected.Value, _rosetteApi.GetCustomHeaders()[expected.Key]);
}
[Test]
public void ClearHeadersTest() {
_rosetteApi.SetCustomHeaders("X-RosetteAPI-Test", "testValue");
_rosetteApi.ClearCustomHeaders();
Assert.IsEmpty(_rosetteApi.GetCustomHeaders());
}
[Test]
public void CheckInvalidCustomHeader() {
KeyValuePair<string, string> expected = new KeyValuePair<string, string>("Test", "testValue");
try {
_rosetteApi.SetCustomHeaders(expected.Key, expected.Value);
}
catch (RosetteException ex) {
Assert.AreEqual(ex.Message, "Custom header name must begin with \"X-RosetteAPI-\"");
return;
}
}
//------------------------- Simple URL Parameter Tests ----------------------------------------
[Test]
public void CustomUrlParametersTest() {
NameValueCollection expected = new NameValueCollection {
{ "output", "rosette" }
};
_rosetteApi.SetUrlParameter("output", "rosette");
Assert.AreEqual(expected["output"], _rosetteApi.GetUrlParameters()["output"]);
}
[Test]
public void ClearUrlParametersTest() {
NameValueCollection expected = new NameValueCollection {
{ "output", "rosette" }
};
_rosetteApi.SetUrlParameter("output", "rosette");
_rosetteApi.ClearUrlParameters();
Assert.IsEmpty(_rosetteApi.GetUrlParameters());
}
[Test]
public void RemoveURLParametersTest() {
NameValueCollection expected = new NameValueCollection {
{ "output", "rosette" }
};
_rosetteApi.RemoveUrlParameter("output");
Assert.IsEmpty(_rosetteApi.GetUrlParameters());
}
//------------------------- Get Calls (Info and Ping) ----------------------------------------
[Test]
public void InfoTest() {
_mockHttp.When(_testUrl + "info")
.Respond("application/json", "{'response': 'OK'}");
var response = _rosetteApi.Info();
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void InfoTestFull()
{
Init();
string name = "Rosette API";
string version = "1.2.3";
string buildNumber = null;
string buildTime = null;
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, object> content = new Dictionary<string, object> {
{ "name", name },
{ "version", version },
{ "buildNumber", buildNumber },
{ "buildTime", buildTime }
};
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, new JavaScriptSerializer().Serialize(content));
_mockHttp.When(_testUrl + "info").Respond(req => mockedMessage);
InfoResponse expected = new InfoResponse(name, version, buildNumber, buildTime, responseHeaders, content);
InfoResponse response = _rosetteApi.Info();
Assert.AreEqual(expected, response);
}
private HttpResponseMessage MakeMockedMessage(Dictionary<string, string> responseHeaders, HttpStatusCode statusCode, String content)
{
HttpResponseMessage mockedMessage = new HttpResponseMessage(statusCode) {
Content = new StringContent(content)
};
foreach (KeyValuePair<string, string> header in responseHeaders)
{
try
{
mockedMessage.Headers.Add(header.Key, header.Value.ToString());
}
catch
{
try
{
mockedMessage.Content.Headers.Add(header.Key, header.Value.ToString());
}
catch
{
switch (header.Key)
{
case "Content-Type": mockedMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(header.Value);
break;
case "content-length": mockedMessage.Content.Headers.ContentLength = long.Parse(header.Value);
break;
default: throw;
}
}
}
}
return mockedMessage;
}
[Test]
public void PingTestFull() {
Init();
string message = "Rosette API at your service.";
long time = 1470930452887;
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, object> content = new Dictionary<string, object> {
{ "message", message },
{ "time", time }
};
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, new JavaScriptSerializer().Serialize(content));
_mockHttp.When(_testUrl + "ping").Respond(req => mockedMessage);
PingResponse expected = new PingResponse(message, time, responseHeaders, content);
PingResponse response = _rosetteApi.Ping();
Assert.AreEqual(expected, response);
}
[Test]
public void PingTest()
{
_mockHttp.When(_testUrl + "ping")
.Respond("application/json", "{'response': 'OK'}");
var response = _rosetteApi.Ping();
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
//------------------------- Exceptions ----------------------------------------
// Currently, the two exceptions returned by the binding (not server) occur if
// neither content nor contentUri are provided or both are provided. Categories is
// used for convenience, but the tests could be run against almost all of the
// endpoints.
[Test]
public void NoParams_Test() {
_mockHttp.When(_testUrl + "categories")
.Respond("application/json", "{'response': 'OK'}");
try {
_rosetteApi.Categories();
}
catch (RosetteException ex) {
Assert.AreEqual(ex.Message, "Must supply one of Content or ContentUri");
return;
}
Assert.Fail("Exception not thrown");
}
[Test]
public void ConflictingParams_Test() {
_mockHttp.When(_testUrl + "categories")
.Respond("application/json", "{'response': 'OK'}");
try {
_rosetteApi.Categories("content", null, null, "contentUri");
}
catch (RosetteException ex) {
Assert.AreEqual(ex.Message, "Cannot supply both Content and ContentUri");
return;
}
Assert.Fail("Exception not thrown");
}
//------------------------- Address Similarity ----------------------------------------
[Test]
public void AddressSimilarityTestFull()
{
Init();
double score = (double)0.9486632809417912;
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "score", score }
};
AddressSimilarityResponse expected = new AddressSimilarityResponse(score, responseHeaders, content, null);
String mockedContent = expected.ContentToString();
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "address-similarity").Respond(req => mockedMessage);
AddressSimilarityResponse response = _rosetteApi.AddressSimilarity(new Address(city:"Cambridge"), new Address(city:"cambridge"));
Assert.AreEqual(expected, response);
}
[Test]
public void AddressSimilarity_Content_Test() {
_mockHttp.When(_testUrl + "address-similarity").Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
Address name1 = new Address("Address One");
Address name2 = new Address("Address Two");
var response = _rosetteApi.AddressSimilarity(name1, name2);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void AddressSimilarity_Dict_Test() {
_mockHttp.When(_testUrl + "address-similarity")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.AddressSimilarity(new Dictionary<object, object>() { { "address1", "Address One" }, { "address2", "Address Two" } });
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
//------------------------- Categories ----------------------------------------
[Test]
public void Categories_Content_Test() {
_mockHttp.When(_testUrl + "categories")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Categories("content");
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void CategoriesContentTestFull()
{
Init();
JsonSerializer serializer = new JsonSerializer();
List<RosetteCategory> categories = new List<RosetteCategory>();
RosetteCategory cat0 = new RosetteCategory("ARTS_AND_ENTERTAINMENT", (decimal)0.23572849069656435, (decimal)0.12312312312312312);
categories.Add(cat0);
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, object> content = new Dictionary<string, object> {
{ "categories", categories }
};
Dictionary<string, string> responseHeaders = serializer.Deserialize<Dictionary<string, string>>(new JsonTextReader(new StringReader(headersAsString)));
String mockedContent = "{\"categories\": [ { \"label\": \"" + cat0.Label + "\", \"confidence\": " + cat0.Confidence + ", \"score\": " + cat0.Score + "} ] }";
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "categories").Respond(req => mockedMessage);
CategoriesResponse expected = new CategoriesResponse(categories, responseHeaders, null, mockedContent);
CategoriesResponse response = _rosetteApi.Categories("Sony Pictures is planning to shoot a good portion of the new \"\"Ghostbusters\"\" in Boston as well.");
Assert.AreEqual(expected, response);
}
[Test]
public void Categories_Dict_Test() {
_mockHttp.When(_testUrl + "categories")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Categories(new Dictionary<object, object>(){ {"contentUri", "contentUrl"} });
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Categories_File_Test() {
_mockHttp.When(_testUrl + "categories")
.Respond("application/json", "{'response': 'OK'}");
RosetteFile f = new RosetteFile(_tmpFile);
var response = _rosetteApi.Categories(f);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
//------------------------- Entity ----------------------------------------
[Test]
public void EntityTestFull()
{
Init();
RosetteEntity e0 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", null, new List<MentionOffset>() { new MentionOffset(0, 10), new MentionOffset(20,32) }, .99, 1, null);
RosetteEntity e1 = new RosetteEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, null, "X1", null, new List<MentionOffset>() { new MentionOffset(15, 18) }, null, null, null);
RosetteEntity e2 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", null, new List<MentionOffset>() { new MentionOffset(0, 10), new MentionOffset(20, 32) }, .99, 0.0, null);
List<RosetteEntity> entities = new List<RosetteEntity>() { e0, e1, e2 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "entities", entities }
};
EntitiesResponse expected = new EntitiesResponse(entities, responseHeaders, content, null);
String mockedContent = expected.ContentToString();
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "entities").Respond(req => mockedMessage);
EntitiesResponse response = _rosetteApi.Entity("Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”");
Assert.AreEqual(expected, response);
}
[Test]
public void EntityTestExtendedProperties() {
// Entities response, based on Cloud defaults, with linkEntities,
// includeDBpediaType, includeDBpediaTypes and includePermID set to true.
Init();
String e_type = "ORGANIZATION";
String e_mention = "Toyota";
String e_normalized = "Toyota";
Nullable<int> e_count = 1;
Nullable<double> e_confidence = null;
List<MentionOffset> e_mentionOffsets = new List<MentionOffset>() { new MentionOffset(0, 6) };
EntityID e_entityID = new EntityID("Q53268");
Nullable<double> e_linkingConfidence = 0.14286868;
Nullable<double> e_salience = null;
String e_dbpediaType = "Agent/Organisation";
List<String> e_dbpediaTypes = new List<String>() {"Agent/Organisation"};
String e_permId = "4295876746";
RosetteEntity e = new RosetteEntity(e_mention, e_normalized, e_entityID, e_type, e_count, e_confidence,
e_dbpediaType, e_dbpediaTypes, e_mentionOffsets, e_linkingConfidence, e_salience, e_permId);
List<RosetteEntity> entities = new List<RosetteEntity>() { e };
Dictionary<string, object> content = new Dictionary<string, object> { { "entities", entities } };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
EntitiesResponse expected = new EntitiesResponse(entities, responseHeaders, content, null);
String mockedContent = expected.ContentToString();
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "entities").Respond(req => mockedMessage);
EntitiesResponse response = _rosetteApi.Entity("Toyota");
Assert.AreEqual(expected, response);
Assert.AreEqual(expected.Entities[0].PermID, response.Entities[0].PermID);
Assert.AreEqual(expected.Entities[0].DBpediaType, response.Entities[0].DBpediaType);
Assert.AreEqual(expected.Entities[0].DBpediaTypes, response.Entities[0].DBpediaTypes);
}
[Test]
public void Entity_Content_Test() {
_mockHttp.When(_testUrl + "entities")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Entity("content");
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Entity_Dict_Test() {
_mockHttp.When(_testUrl + "entities")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Entity(new Dictionary<object, object>() { { "contentUri", "contentUrl" } });
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Entity_File_Test() {
_mockHttp.When(_testUrl + "entities")
.Respond("application/json", "{'response': 'OK'}");
RosetteFile f = new RosetteFile(_tmpFile);
var response = _rosetteApi.Entity(f);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void EntityIDTestPassOnCreate()
{
EntityID pass = new EntityID("Q1") {
ID = "Q1"
};
Assert.AreEqual("https://en.wikipedia.org/wiki/Universe", pass.GetWikipediaURL());
}
[Test]
public void EntityIDTestLinkValidOnSet() {
EntityID tidAtFirst = new EntityID("T423");
Assert.AreEqual(null, tidAtFirst.GetWikipediaURL());
tidAtFirst.ID = "Q2";
Assert.AreEqual("https://en.wikipedia.org/wiki/Earth", tidAtFirst.GetWikipediaURL());
}
[Test]
public void EntityIDLinkNullOnSetToNull()
{
EntityID eid = new EntityID(null);
Assert.AreEqual(null, eid.GetWikipediaURL());
}
//------------------------- Language ----------------------------------------
[Test]
public void LanguageTestFull()
{
Init();
LanguageDetection lang0 = new LanguageDetection("spa", (decimal)0.38719602327387076);
LanguageDetection lang1 = new LanguageDetection("eng", (decimal)0.32699986625091865);
LanguageDetection lang2 = new LanguageDetection("por", (decimal)0.05569054210624943);
LanguageDetection lang3 = new LanguageDetection("deu", (decimal)0.030069489878380328);
LanguageDetection lang4 = new LanguageDetection("zho", (decimal)0.23572849069656435);
LanguageDetection lang5 = new LanguageDetection("swe", (decimal)0.027734757034048835);
LanguageDetection lang6 = new LanguageDetection("ces", (decimal)0.02583105013400886);
LanguageDetection lang7 = new LanguageDetection("fin", (decimal)0.23572849069656435);
LanguageDetection lang8 = new LanguageDetection("fra", (decimal)0.023298946617300347);
List<LanguageDetection> languageDetections = new List<LanguageDetection>() { lang0, lang1, lang2, lang3, lang4, lang5, lang6, lang7, lang8 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "languageDetections", languageDetections }
};
LanguageIdentificationResponse expected = new LanguageIdentificationResponse(languageDetections, responseHeaders, content, null);
String mockedContent = expected.ContentToString();
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "language").Respond(req => mockedMessage);
LanguageIdentificationResponse response = _rosetteApi.Language("Por favor Señorita, says the man.");
Assert.AreEqual(expected, response);
}
[Test]
public void Language_Content_Test() {
_mockHttp.When(_testUrl + "language")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Language("content");
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Language_Dict_Test() {
_mockHttp.When(_testUrl + "language")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Language(new Dictionary<object, object>() { { "contentUri", "contentUrl" } });
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Language_File_Test() {
_mockHttp.When(_testUrl + "language")
.Respond("application/json", "{'response': 'OK'}");
RosetteFile f = new RosetteFile(_tmpFile);
var response = _rosetteApi.Language(f);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
//------------------------- Morphology ----------------------------------------
[Test]
public void MorphologyTestFullComplete()
{
Init();
MorphologyItem m0 = new MorphologyItem("The", "DET", "the", new List<string>(), new List<string>());
MorphologyItem m1 = new MorphologyItem("quick", "ADJ", "quick", new List<string>(), new List<string>());
MorphologyItem m2 = new MorphologyItem("brown", "ADJ", "brown", new List<string>(), new List<string>());
MorphologyItem m3 = new MorphologyItem("fox", "NOUN", "fox", new List<string>(), new List<string>());
MorphologyItem m4 = new MorphologyItem("jumped", "VERB", "jump", new List<string>(), new List<string>());
MorphologyItem m5 = new MorphologyItem(".", "PUNCT", ".", new List<string>(), new List<string>());
List<MorphologyItem> morphology = new List<MorphologyItem>() { m0, m1, m2, m3, m4, m5 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "tokens", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Token)) },
{ "posTags", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.PosTag)) },
{ "lemmas", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Lemma)) },
{ "compoundComponents", new List<List<string>>(morphology.Select<MorphologyItem, List<string>>((item) => item.CompoundComponents)) },
{ "hanReadings", new List<List<string>>(morphology.Select<MorphologyItem, List<string>>((item) => item.HanReadings)) }
};
MorphologyResponse expected = new MorphologyResponse(morphology, responseHeaders, content, null);
String mockedContent = expected.ContentAsJson;
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "morphology/complete").Respond(req => mockedMessage);
MorphologyResponse response = _rosetteApi.Morphology("The quick brown fox jumped.");
Assert.AreEqual(expected, response);
}
[Test]
public void MorphologyTestFullLemmas()
{
Init();
MorphologyItem m0 = new MorphologyItem("The", null, "the", null, null);
MorphologyItem m1 = new MorphologyItem("quick", null, "quick", null, null);
MorphologyItem m2 = new MorphologyItem("brown", null, "brown", null, null);
MorphologyItem m3 = new MorphologyItem("fox", null, "fox", null, null);
MorphologyItem m4 = new MorphologyItem("jumped", null, "jump", null, null);
MorphologyItem m5 = new MorphologyItem(".", null, ".", null, null);
List<MorphologyItem> morphology = new List<MorphologyItem>() { m0, m1, m2, m3, m4, m5 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "tokens", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Token)) }
};
;
content.Add("lemmas", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Lemma)));
MorphologyResponse expected = new MorphologyResponse(morphology, responseHeaders, content, null);
String mockedContent = expected.ContentAsJson;
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "morphology/lemmas").Respond(req => mockedMessage);
MorphologyResponse response = _rosetteApi.Morphology("The quick brown fox jumped.", feature: MorphologyFeature.lemmas);
Assert.AreEqual(expected, response);
}
[Test]
public void MorphologyTestFullCompoundComponents()
{
Init();
MorphologyItem m0 = new MorphologyItem("Er", null, null, new List<string>(), null);
List<string> compoundComponents = new List<string>() { "Rechts", "Schutz", "Versicherungs", "Gesellschaft" };
MorphologyItem m1 = new MorphologyItem("Rechtsschutzversicherungsgesellschaft", null, null, compoundComponents, null);
List<MorphologyItem> morphology = new List<MorphologyItem>() { m0, m1 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "tokens", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Token)) }
};
;
content.Add("compoundComponents", new List<List<string>>(morphology.Select<MorphologyItem, List<string>>((item) => item.CompoundComponents)));
MorphologyResponse expected = new MorphologyResponse(morphology, responseHeaders, content, null);
String mockedContent = expected.ContentAsJson;
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "morphology/compound-components").Respond(req => mockedMessage);
MorphologyResponse response = _rosetteApi.Morphology("Er Rechtsschutzversicherungsgesellschaft.", feature: MorphologyFeature.compoundComponents);
Assert.AreEqual(expected, response);
}
[Test]
public void MorphologyTestFullHanReadings()
{
Init();
List<string> h0 = new List<string>() { "Bei3-jing1-Da4-xue2" };
List<string> h1 = null;
List<string> h2 = new List<string>() { "zhu3-ren4" };
MorphologyItem m0 = new MorphologyItem("北京大学", null, null, null, h0);
MorphologyItem m1 = new MorphologyItem("生物系", null, null, null, h1);
MorphologyItem m2 = new MorphologyItem("主任", null, null, null, h2);
List<MorphologyItem> morphology = new List<MorphologyItem>() { m0, m1, m2 };
string headersAsString = " { \"Content-Type\": \"application/json\", \"Date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"Server\": \"openresty\", \"Strict-Transport-Security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"Content-Length\": \"72\", \"Connection\": \"Close\" }";
Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
Dictionary<string, object> content = new Dictionary<string, object> {
{ "tokens", new List<string>(morphology.Select<MorphologyItem, string>((item) => item.Token)) }
};
;
content.Add("hanReadings", new List<List<string>>(morphology.Select<MorphologyItem, List<string>>((item) => item.HanReadings)));
MorphologyResponse expected = new MorphologyResponse(morphology, responseHeaders, content, null);
String mockedContent = expected.ContentAsJson;
HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
_mockHttp.When(_testUrl + "morphology/han-readings").Respond(req => mockedMessage);
MorphologyResponse response = _rosetteApi.Morphology("北京大学生物系主任.", feature: MorphologyFeature.hanReadings);
Assert.AreEqual(expected, response);
}
[Test]
public void Morphology_Content_Test() {
_mockHttp.When(_testUrl + "morphology/complete")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Morphology("content");
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Morphology_Dict_Test() {
_mockHttp.When(_testUrl + "morphology/complete")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");
var response = _rosetteApi.Morphology(new Dictionary<object, object>() { { "contentUri", "contentUrl" } });
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}
[Test]
public void Morphology_File_Test() {
_mockHttp.When(_testUrl + "morphology/complete")
.Respond("application/json", "{'response': 'OK'}");