public async Task GetAllPositionsAsync_WithIncorrectData_ShouldntReturnAllPositions() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var positionService = new PositionService(context); var result = await positionService.GetAllPositionsAsync(); Assert.True(result.Count() == 0); }
public async Task GetRandomPositionAsync_WithIncorrectData_ShouldntReturnRandomPosition() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var positionService = new PositionService(context); var getRandomPosition = await positionService.GetRandomPositionAsync(); Assert.True(getRandomPosition == null); }
public async Task GetRandomSupportBuildAsync_WithIncorrectData_ShouldntReturnCompleteRandomSupportBuild() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); var getRandomBuild = await itemService.GetRandomSupportBuildAsync(); Assert.True(getRandomBuild.Count() < 6); }
public async Task GetRandomSummonerSpellsAsync_WithIncorrectData_ShouldntReturnRandomSummonerSpells() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var summonerSpellService = new SummonerSpellService(context); var getRandomSummonerSpells = await summonerSpellService.GetRandomSummonerSpellsAsync(); Assert.True(getRandomSummonerSpells.Count() == 0); }
public async Task GetRandomJungleBuildAsync_WithCorrectData_ShouldReturnRandomJungleBuildWithJungleItem() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); SeedTestItems(context); var getRandomBuild = await itemService.GetRandomJungleBuildAsync(); Assert.Contains(getRandomBuild, x => x.Type.Equals(ItemType.Jungle)); }
public async Task GetPositionByIdAsync_WithCorrectData_ShouldReturnPositionById(int id) { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var positionService = new PositionService(context); SeedTestPositions(context); var position = await positionService.GetPositionByIdAsync(id); Assert.True(position.Id == id); }
public async Task GetChampionByIdAsync_WithIncorrectData_ShouldntReturnChampionById(int id) { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var championService = new ChampionService(context); SeedTestChampions(context); var champion = await championService.GetChampionByIdAsync(id); Assert.True(champion == null); }
public async Task GetAllChampionsAsync_WithCorrectData_ShouldReturnAllChampions() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var championService = new ChampionService(context); SeedTestChampions(context); var result = await championService.GetAllChampionsAsync(); Assert.True(result.Count() == 5); }
public async Task GetRandomBuildAsync_WithCorrectData_ShouldReturnRandomBuildWithSixItems() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); SeedTestItems(context); var getRandomBuild = await itemService.GetRandomBuildAsync(); Assert.Equal(6, getRandomBuild.Count()); }
public async Task GetRandomChampionAsync_WithCorrectData_ShouldReturnRandomChampion() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var championService = new ChampionService(context); SeedTestChampions(context); var getRandomChampion = await championService.GetRandomChampionAsync(); Assert.True(getRandomChampion != null); }
public async Task GetRandomBuildForPositionAsync_WithInorrectData_ShouldntReturnCompleteRandomBuildForTopOrMidOrBotPositon(int id) { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); SeedTestPositions(context); var getRandomBuild = await itemService.GetRandomBuildForPositionAsync(id); Assert.True(getRandomBuild.Count() < 6); }
public async Task GetRandomBuildForPositionAsync_WithCorrectData_ShouldReturnRandomBuildForSupportPositonWithSixItems(int id) { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); SeedTestItems(context); SeedTestPositions(context); var getRandomBuild = await itemService.GetRandomBuildForPositionAsync(id); Assert.True(getRandomBuild.Count() == 6); }
public async Task GetRandomBuildForPositionAsync_WithCorrectData_ShouldReturnRandomBuildForTopOrMidOrBotPositonWithBoots(int id) { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var itemService = new ItemService(context); SeedTestItems(context); SeedTestPositions(context); var getRandomBuild = await itemService.GetRandomBuildForPositionAsync(id); Assert.Contains(getRandomBuild, x => x.Type.Equals(ItemType.Boots)); }
public async Task GetJunglerSummonerSpellsAsync_WithInorrectData_ShouldntReturnSmite() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var summonerSpellService = new SummonerSpellService(context); var smite = new SummonerSpell() { Id = 10, Name = "Smite" }; SeedTestSummonerSpells(context); var getJunglerSummonerSpells = await summonerSpellService.GetJunglerSummonerSpellsAsync(); Assert.DoesNotContain(smite, getJunglerSummonerSpells); }
public async Task GetJunglerSummonerSpellsAsync_WithCorrectData_ShouldReturnSmiteAndOneRandomSummonerSpell() { var options = new DbContextOptionsBuilder <LeagueDraftDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new LeagueDraftDbContext(options); var summonerSpellService = new SummonerSpellService(context); var smite = new SummonerSpell() { Id = 10, Name = "Smite" }; await context.SummonerSpells.AddAsync(smite); SeedTestSummonerSpells(context); var getJunglerSummonerSpells = await summonerSpellService.GetJunglerSummonerSpellsAsync(); Assert.True(getJunglerSummonerSpells.Count() == 2 && getJunglerSummonerSpells.Contains(smite)); }
public DataService(LeagueDraftDbContext context) { this.context = context; }
private void SeedTestPositions(LeagueDraftDbContext context) { context.Positions.AddRange(GetPositions()); context.SaveChanges(); }
public ItemService(LeagueDraftDbContext context) : base(context) { }
public ChampionService(LeagueDraftDbContext context) : base(context) { }
public SummonerSpellService(LeagueDraftDbContext context) : base(context) { }
private void SeedTestSummonerSpells(LeagueDraftDbContext context) { context.SummonerSpells.AddRange(GetSummonerSpells()); context.SaveChanges(); }
private void SeedTestItems(LeagueDraftDbContext context) { context.Items.AddRange(GetTestItems()); context.SaveChanges(); }