Пример #1
0
        public async Task ShouldLoadCatWithDependency_WhenFilterAskTo()
        {
            using (var dbContext = DbContextFixture.GetDbContext())
            {
                var service = new CatService(new HttpService(), dbContext, IConfigMock.GetCatsMock());
                var cat     = await service.Get(1, new RequestOptions()
                {
                    IncludeMatchHistory = true
                }).ConfigureAwait(false);

                Assert.NotNull(cat);
                Assert.NotNull(cat.Rank);
                Assert.NotNull(cat.Informations);
                Assert.Empty(cat.Informations.History);
            }
        }
Пример #2
0
        public async Task ShouldInjectCats_ProvidedByApi()
        {
            using (var dbContext = DbContextFixture.GetDbContext())
            {
                var service       = new CatService(new HttpService(), dbContext, IConfigMock.GetCatsMock());
                var previousCount = dbContext.Cats.Count();

                await service.InjectCats().ConfigureAwait(false);

                Cat[] cats = dbContext.Cats.ToArray();

                Assert.NotNull(cats);
                Assert.NotEmpty(cats);
                Assert.True(previousCount == cats.Length);
            }
        }
Пример #3
0
        public async Task ShouldLoadAllCatsWithRank_WhenOptionsFilterApplyied()
        {
            using (var dbContext = DbContextFixture.GetDbContext())
            {
                var         service = new CatService(new HttpService(), dbContext, IConfigMock.GetCatsMock());
                IList <Cat> cats    = (await service.GetAll(new RequestOptions()
                {
                    Count = 5,
                    Offset = 0,
                    EloFilter = new MinMaxFilter()
                    {
                        Min = 1200, Max = 1500
                    },
                    IncludeMatchHistory = true
                }).ConfigureAwait(false)).ToList();

                Assert.NotNull(cats);
                Assert.NotEmpty(cats);
                Assert.True(cats.Count == 5);
                Assert.NotNull(cats[0].Rank);
                Assert.NotNull(cats[0].Informations);
                Assert.NotNull(cats[0].Informations.History);
            }
        }
Пример #4
0
        public async Task ShouldFindMatch_WhenCatsAreAvailable()
        {
            using (var dbContext = DbContextFixture.GetDbContext())
            {
                IMatchService service    = new MatchService(dbContext, new RankingService(RankingValues.Limit, RankingValues.EvolutionCoef));
                ICatService   catService = new CatService(new HttpService(), dbContext, IConfigMock.GetCatsMock());
                await catService.InjectCats().ConfigureAwait(false); // Prepare cats

                MatchIds matchIds = await service.FindMatchAsync().ConfigureAwait(false);

                Assert.NotEqual(0, matchIds.Left);
                Assert.NotEqual(0, matchIds.Right);
            }
        }