public async Task GetTWithValidId() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var repository = new EfDeletableEntityRepository <GamingHall>(dbContext); UsersHallsService usersHallsService = new UsersHallsService(new EfRepository <UsersHalls>(dbContext)); var service = new GamingHallService(repository, usersHallsService); await service.AddAsync( "hall1", null, "desc1", "1111", "adress1", "town", "1"); var hall = await dbContext.GamingHalls.FirstOrDefaultAsync(); var result = service.GetT <DetailsViewModel>(hall.Id); Assert.Equal(hall.HallName, result.HallName); Assert.Equal(hall.ImageUrl, result.ImageUrl); Assert.Equal(hall.Description, result.Description); Assert.Equal(hall.PhoneNumber, result.PhoneNumber); Assert.Equal(hall.Adress, result.Adress); Assert.Equal(hall.Town, result.Town); dbContext.Database.EnsureDeleted(); }
public async Task GetTWithNullId() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var repository = new EfDeletableEntityRepository <GamingHall>(dbContext); UsersHallsService usersHallsService = new UsersHallsService(new EfRepository <UsersHalls>(dbContext)); var service = new GamingHallService(repository, usersHallsService); await service.AddAsync( "hall1", null, "desc1", "1111", "adress1", "town", "1"); var result = service.GetT <DetailsViewModel>(null); Assert.Null(result); dbContext.Database.EnsureDeleted(); }