File tree Expand file tree Collapse file tree 3 files changed +109
-0
lines changed
src/Inshapardaz.Domain/Models
tests/Inshapardaz.Api.Tests/Tools/CommonWords/GetCommonWordsByLanguage Expand file tree Collapse file tree 3 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 1+ namespace Inshapardaz . Domain . Models ;
2+
3+ public class CommonWordModel
4+ {
5+ public long Id { get ; set ; }
6+ public string Language { get ; set ; }
7+ public string Word { get ; set ; }
8+ }
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Linq ;
3+ using System . Net . Http ;
4+ using System . Threading . Tasks ;
5+ using Bogus ;
6+ using FluentAssertions ;
7+ using Inshapardaz . Api . Tests . Framework . Asserts ;
8+ using Newtonsoft . Json ;
9+ using NUnit . Framework ;
10+
11+ namespace Inshapardaz . Api . Tests . Tools . CommonWords . GetCommonWordsByLanguage
12+ {
13+ [ TestFixture ]
14+ public class WhenGettingCommonWordsByLanguage : TestBase
15+ {
16+ private HttpResponseMessage _response ;
17+ private IEnumerable < string > _responsePayload ;
18+ private readonly string _language = new Faker ( ) . Random . String2 ( 4 ) ;
19+
20+ public WhenGettingCommonWordsByLanguage ( )
21+ : base ( Domain . Models . Role . Reader )
22+ {
23+ }
24+
25+ [ OneTimeSetUp ]
26+ public async Task Setup ( )
27+ {
28+ CommonWordBuilder . WithLanguage ( _language ) . Build ( 12 ) ;
29+
30+ _response = await Client . GetAsync ( $ "/tools/{ _language } /words/list") ;
31+ var payload = await _response . Content . ReadAsStringAsync ( ) ;
32+ _responsePayload = JsonConvert . DeserializeObject < IEnumerable < string > > ( payload ) ;
33+ }
34+
35+ [ OneTimeTearDown ]
36+ public void Teardown ( )
37+ {
38+ Cleanup ( ) ;
39+ }
40+
41+ [ Test ]
42+ public void ShouldReturnOk ( )
43+ {
44+ _response . ShouldBeOk ( ) ;
45+ }
46+
47+ [ Test ]
48+ public void ShouldReturnExpectedData ( )
49+ {
50+ var expectedItems = CommonWordBuilder . Words . OrderBy ( a => a . Word ) . Select ( x => x . Word ) ;
51+ _responsePayload . Should ( ) . Equal ( expectedItems ) ;
52+ }
53+ }
54+ }
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Linq ;
3+ using System . Net . Http ;
4+ using System . Threading . Tasks ;
5+ using Bogus ;
6+ using FluentAssertions ;
7+ using Inshapardaz . Api . Tests . Framework . Asserts ;
8+ using Newtonsoft . Json ;
9+ using NUnit . Framework ;
10+
11+ namespace Inshapardaz . Api . Tests . Tools . CommonWords . GetCommonWordsByLanguage
12+ {
13+ [ TestFixture ]
14+ public class WhenGettingCommonWordsByUnknownLanguage : TestBase
15+ {
16+ private HttpResponseMessage _response ;
17+ private IEnumerable < string > _responsePayload ;
18+ private readonly string _language = new Faker ( ) . Random . String2 ( 4 ) ;
19+
20+ public WhenGettingCommonWordsByUnknownLanguage ( )
21+ : base ( Domain . Models . Role . Reader )
22+ {
23+ }
24+
25+ [ OneTimeSetUp ]
26+ public async Task Setup ( )
27+ {
28+ CommonWordBuilder . WithLanguage ( _language ) . Build ( 4 ) ;
29+
30+ _response = await Client . GetAsync ( $ "/tools/-{ _language } /words/list") ;
31+ var payload = await _response . Content . ReadAsStringAsync ( ) ;
32+ _responsePayload = JsonConvert . DeserializeObject < IEnumerable < string > > ( payload ) ;
33+ }
34+
35+ [ OneTimeTearDown ]
36+ public void Teardown ( )
37+ {
38+ Cleanup ( ) ;
39+ }
40+
41+ [ Test ]
42+ public void ShouldReturnNotFound ( )
43+ {
44+ _response . ShouldBeNotFound ( ) ;
45+ }
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments