public async Task AllWithInvalidlId() { ApplicationDbContext dbContextWins = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var service = new WinsService(new EfDeletableEntityRepository <Win>(dbContextWins)); var date = DateTime.UtcNow; for (int i = 1; i < 6; i++) { await service.AddAsync( "http://wwww.test.img" + i, "desc", date, "1", "1"); } int page = 1; int itemPerPage = 3; AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly); var wins = service.All <WinViewModel>("2", itemPerPage, (page - 1) * itemPerPage); int count = 0; foreach (var win in wins) { count++; } Assert.Equal(0, count); dbContextWins.Database.EnsureDeleted(); }
public async Task GetGalleryCountWithNoexistingName() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var repository = new EfDeletableEntityRepository <Win>(dbContext); var service = new WinsService(repository); var date = DateTime.UtcNow; await service.AddAsync( "http://wwww.test.img", "desc", date, "1", "1"); Assert.Equal(0, service.GetWinsCount("11")); dbContext.Database.EnsureDeleted(); }
public async Task GetHallIdWithValidId() { ApplicationDbContext dbContextWins = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var service = new WinsService(new EfDeletableEntityRepository <Win>(dbContextWins)); var date = DateTime.UtcNow; await service.AddAsync( "http://wwww.test.img", "desc", date, "1", "1"); var win = await dbContextWins.Wins.FirstOrDefaultAsync(); string hallId = service.GetHallId(win.Id); Assert.Equal("1", hallId); dbContextWins.Database.EnsureDeleted(); }