@@ -122,6 +122,45 @@ public async Task Can_Fetch_Many_To_Many_Through_GetById()
122122 Assert . Equal ( tag . Name , tagResponse . Name ) ;
123123 }
124124
125+ [ Fact ]
126+ public async Task Can_Fetch_Many_To_Many_Through_Id ( )
127+ {
128+ // Arrange
129+ var context = _fixture . GetService < AppDbContext > ( ) ;
130+ var article = _articleFaker . Generate ( ) ;
131+ var tag = _tagFaker . Generate ( ) ;
132+ var articleTag = new ArticleTag
133+ {
134+ Article = article ,
135+ Tag = tag
136+ } ;
137+ context . ArticleTags . Add ( articleTag ) ;
138+ await context . SaveChangesAsync ( ) ;
139+
140+ var route = $ "/api/v1/articles/{ article . Id } /tags";
141+
142+ // @TODO - Use fixture
143+ var builder = new WebHostBuilder ( )
144+ . UseStartup < Startup > ( ) ;
145+ var server = new TestServer ( builder ) ;
146+ var client = server . CreateClient ( ) ;
147+
148+ // Act
149+ var response = await client . GetAsync ( route ) ;
150+
151+ // Assert
152+ var body = await response . Content . ReadAsStringAsync ( ) ;
153+ Assert . True ( HttpStatusCode . OK == response . StatusCode , $ "{ route } returned { response . StatusCode } status code with payload: { body } ") ;
154+
155+ var document = JsonConvert . DeserializeObject < Document > ( body ) ;
156+ Assert . Single ( document . ManyData ) ;
157+
158+ var tagResponse = _fixture . GetDeserializer ( ) . DeserializeList < Tag > ( body ) . Data . First ( ) ;
159+ Assert . NotNull ( tagResponse ) ;
160+ Assert . Equal ( tag . Id , tagResponse . Id ) ;
161+ Assert . Equal ( tag . Name , tagResponse . Name ) ;
162+ }
163+
125164 [ Fact ]
126165 public async Task Can_Fetch_Many_To_Many_Through_GetById_Relationship_Link ( )
127166 {
@@ -160,7 +199,6 @@ public async Task Can_Fetch_Many_To_Many_Through_GetById_Relationship_Link()
160199 Assert . Equal ( tag . Id , tagResponse . Id ) ;
161200 }
162201
163-
164202 [ Fact ]
165203 public async Task Can_Fetch_Many_To_Many_Through_Relationship_Link ( )
166204 {
0 commit comments