@@ -21,11 +21,15 @@ public class CaptionsControllerTest : BaseControllerTest
2121 public CaptionsControllerTest ( GlobalFixture fixture ) : base ( fixture )
2222 {
2323 _controller = new CaptionsController (
24- ( WakeDownloader ) fixture . _serviceProvider . GetService ( typeof ( WakeDownloader ) ) ,
24+ ( WakeDownloader ) fixture . _serviceProvider . GetService ( typeof ( WakeDownloader ) ) ,
2525 _context ,
2626 new CaptionQueries ( _context ) ,
27+ _userUtils ,
2728 null
28- ) ;
29+ )
30+ {
31+ ControllerContext = fixture . _controllerContext
32+ } ;
2933 }
3034
3135 [ Fact ]
@@ -146,7 +150,7 @@ public async Task Post_Caption_Success()
146150 Text = "foo bar" ,
147151 CaptionType = CaptionType . TextCaption
148152 } ;
149-
153+ _context . Users . Add ( new ApplicationUser { Id = TestGlobals . TEST_USER_ID } ) ;
150154 _context . Captions . Add ( caption ) ;
151155 _context . SaveChanges ( ) ;
152156
@@ -162,6 +166,9 @@ public async Task Post_Caption_Success()
162166 [ Fact ]
163167 public async Task Post_Caption_Fail ( )
164168 {
169+ _context . Users . Add ( new ApplicationUser { Id = TestGlobals . TEST_USER_ID } ) ;
170+ _context . SaveChanges ( ) ;
171+
165172 var result = await _controller . PostCaption ( null ) ;
166173 Assert . IsType < BadRequestObjectResult > ( result . Result ) ;
167174
@@ -320,7 +327,7 @@ public async Task Search_In_Offering_Fail()
320327 public async Task Search_In_Offering ( )
321328 {
322329 var video = new Video { Id = "789" } ;
323-
330+
324331 var transcriptions = new List < Transcription > ( )
325332 {
326333 new Transcription
@@ -359,9 +366,9 @@ public async Task Search_In_Offering()
359366 } ;
360367 var course = new Course { Id = "cid1" } ;
361368 var offering = new Offering { Id = "oid8" } ;
362- var CourseOffering = new CourseOffering { Id = "2123000" , CourseId = "cid1" , OfferingId = "oid8" } ;
363- var playlist = new Playlist { Id = "2456" , OfferingId = offering . Id , Name = "Playlist 1" } ;
364- var media = new Media { Id = "2678" , PlaylistId = playlist . Id , VideoId = video . Id , Name = "Media 1" } ;
369+ var CourseOffering = new CourseOffering { Id = "2123000" , CourseId = "cid1" , OfferingId = "oid8" } ;
370+ var playlist = new Playlist { Id = "2456" , OfferingId = offering . Id , Name = "Playlist 1" } ;
371+ var media = new Media { Id = "2678" , PlaylistId = playlist . Id , VideoId = video . Id , Name = "Media 1" } ;
365372 _context . Courses . Add ( course ) ;
366373 _context . Offerings . Add ( offering ) ;
367374 _context . CourseOfferings . Add ( CourseOffering ) ;
@@ -379,23 +386,24 @@ public async Task Search_In_Offering()
379386 var onlyEnglishResults = await _controller . SearchInOffering ( offering . Id , "fortran" ) ;
380387 Assert . Single ( onlyEnglishResults . Value ) ;
381388
382- var bothResults = await _controller . SearchInOffering ( offering . Id , "fortran" , "" ) ;
383-
389+ var bothResults = await _controller . SearchInOffering ( offering . Id , "fortran" , "" ) ;
390+
384391 List < SearchedCaptionDTO > bothResultList = bothResults . Value . ToList ( ) ;
385392 Assert . Equal ( captions . Count , bothResultList . Count ( ) ) ;
386- for ( int i = 0 ; i < captions . Count ; i ++ ) {
393+ for ( int i = 0 ; i < captions . Count ; i ++ )
394+ {
387395 Assert . Equal ( captions [ i ] . Text , bothResultList [ i ] . Caption . Text ) ;
388- Assert . Equal ( transcriptions [ i ] . Language , bothResultList [ i ] . Language ) ;
396+ Assert . Equal ( transcriptions [ i ] . Language , bothResultList [ i ] . Language ) ;
389397 }
390398
391399 var oneFrenchResult = await _controller . SearchInOffering ( offering . Id , "fortran" , "fr" ) ;
392-
400+
393401 Assert . Single ( oneFrenchResult . Value ) ;
394- var c = oneFrenchResult . Value . First ( ) ;
395- Assert . Equal ( captions [ 1 ] . Text , c . Caption . Text ) ;
402+ var c = oneFrenchResult . Value . First ( ) ;
403+ Assert . Equal ( captions [ 1 ] . Text , c . Caption . Text ) ;
396404 Assert . Null ( c . Caption . Transcription ) ;
397-
398- Assert . Equal ( media . Id , c . MediaId ) ;
405+
406+ Assert . Equal ( media . Id , c . MediaId ) ;
399407 Assert . Equal ( playlist . Id , c . PlaylistId ) ;
400408 Assert . Equal ( media . Name , c . MediaName ) ;
401409 Assert . Equal ( playlist . Name , c . PlaylistName ) ;
0 commit comments