コード例 #1
0
        public WhenSeriesAssemblerWorksCorrectly()
        {
            var jikanMockBuilder = new JikanMockBuilder();
            var franchises       = Config.GetSection("Jikan:Anime:Franchises").GetChildren().Select(c => c.Key).ToArray();

            foreach (var franchise in franchises)
            {
                jikanMockBuilder.HasAnimes(Config.GetSection($"Jikan:Anime:Franchises:{franchise}").Get <long[]>());
            }
            franchises = Config.GetSection("Jikan:Manga:Franchises").GetChildren().Select(c => c.Key).ToArray();
            foreach (var franchise in franchises)
            {
                jikanMockBuilder.HasMangas(Config.GetSection($"Jikan:Manga:Franchises:{franchise}").Get <long[]>());
            }
            var jikanMock   = jikanMockBuilder.Build();
            var ignoredRepo = new Mock <IIgnoredEntriesRepository>();

            ignoredRepo.SetReturnsDefault(false);
            var ignoredAnimeIds = Config.GetSection($"Ignored:Anime").Get <long[]>();

            foreach (var id in ignoredAnimeIds)
            {
                ignoredRepo.Setup(r => r.IsIgnored(id, EntrySource.Anime)).ReturnsAsync(true);
            }
            var serviceProvider = new Mock <IEntryProviderFactory>();

            serviceProvider.Setup(s => s.Get(EntrySource.Anime)).Returns(new JikanAnimeProvider(jikanMock.Object, ignoredRepo.Object));
            serviceProvider.Setup(s => s.Get(EntrySource.Manga)).Returns(new JikanMangaProvider(jikanMock.Object, ignoredRepo.Object));
            franchiseService = new FranchiseService(serviceProvider.Object, new FranchiseAssembler(new RelationService()));

            var values = Config.GetSection("Jikan:Entries").GetChildren().Select(c => new { c.Key, Value = long.Parse(c.Value) });

            values.ForEach(v => malDictionary.Add(v.Key, v.Value));
        }
コード例 #2
0
        public WhenFranchiseAlgorithmsWorkCorrectly()
        {
            var jikanMockBuilder     = new JikanMockBuilder();
            var franchisesOfInterest = Config.GetSection("Jikan:Anime:Franchises").GetChildren().Select(c => c.Key).ToArray();

            foreach (var franchiseName in franchisesOfInterest)
            {
                var entries = Config.GetSection($"Jikan:Anime:Franchises:{franchiseName}").Get <long[]>();
                franchises[franchiseName] = entries;
                jikanMockBuilder.HasAnimes(entries);
            }
            jikanMock = jikanMockBuilder.Build();

            franchiseService = new FranchiseService(null, null);
        }