コード例 #1
0
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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));
        }
コード例 #16
0
 public DataService(LeagueDraftDbContext context)
 {
     this.context = context;
 }
コード例 #17
0
 private void SeedTestPositions(LeagueDraftDbContext context)
 {
     context.Positions.AddRange(GetPositions());
     context.SaveChanges();
 }
コード例 #18
0
 public ItemService(LeagueDraftDbContext context) : base(context)
 {
 }
コード例 #19
0
 public ChampionService(LeagueDraftDbContext context) : base(context)
 {
 }
コード例 #20
0
 public SummonerSpellService(LeagueDraftDbContext context) : base(context)
 {
 }
コード例 #21
0
 private void SeedTestSummonerSpells(LeagueDraftDbContext context)
 {
     context.SummonerSpells.AddRange(GetSummonerSpells());
     context.SaveChanges();
 }
コード例 #22
0
 private void SeedTestItems(LeagueDraftDbContext context)
 {
     context.Items.AddRange(GetTestItems());
     context.SaveChanges();
 }