public async Task SearchGuideShouldFindOneByTitle() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var context = new ApplicationDbContext(options.Options); await context.Users.AddAsync(new ApplicationUser() { Id = "2" }); await context.Games.AddAsync(new Game() { Id = "1" }); var postRepository = new EfDeletableEntityRepository <Post>(context); var guideRepository = new EfDeletableEntityRepository <Guide>(context); var searchBarService = new SearchBarService(postRepository, guideRepository); var guideService = new GuidesService(guideRepository); var guideModel = new CreateGuideInputModel() { Title = "testtesttest", Category = "Action", Description = "sssss", GameId = "1", ImageUrl = "test", }; await guideService.CreateAsync(guideModel, "2"); var actual = await searchBarService.SearchGuide <GuideViewModel>("test", 5, 0); Assert.Single(actual); }
public async Task SearchGuideShouldTakeFive() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var context = new ApplicationDbContext(options.Options); await context.Users.AddAsync(new ApplicationUser() { Id = "1" }); await context.Games.AddAsync(new Game() { Id = "1" }); var postRepository = new EfDeletableEntityRepository <Post>(context); var guideRepository = new EfDeletableEntityRepository <Guide>(context); var searchBarService = new SearchBarService(postRepository, guideRepository); var guideService = new GuidesService(guideRepository); var guideModels = new List <CreateGuideInputModel>() { new CreateGuideInputModel() { Title = "new", Category = "Action", Description = "test", GameId = "1", ImageUrl = "google", }, new CreateGuideInputModel() { Title = "new", Category = "Action", Description = "test1", ImageUrl = "google", GameId = "1", }, new CreateGuideInputModel() { Title = "testttt", Category = "Action", Description = "new", ImageUrl = "google", GameId = "1", }, new CreateGuideInputModel() { Title = "new", Category = "Action", Description = "test5", ImageUrl = "google", GameId = "1", }, new CreateGuideInputModel() { Title = "new", Category = "Action", Description = "test7", ImageUrl = "google", GameId = "1", }, new CreateGuideInputModel() { Title = "newtest3", Category = "Action", Description = "eee", ImageUrl = "google", GameId = "1", }, }; foreach (var guideModel in guideModels) { await guideService.CreateAsync(guideModel, "1"); } var actual = await searchBarService.SearchGuide <GuideViewModel>("test", 5, 0); Assert.Equal(5, actual.Count()); }