Esempio n. 1
0
        public RecentSearchClientServiceTests()
        {
            var secretManager = new UserSecretManager();
            var apiKey        = secretManager.GetTwitterApiKey();

            _recentSearchService = new RecentSearchService(apiKey);
        }
Esempio n. 2
0
        public TweetRepositoryFixture()
        {
            // Secrets.
            secretManager = new UserSecretManager();
            integrationConnectionString = secretManager.GetDataConnectionStringApiKey("integration");
            twitterApiKey = secretManager.GetTwitterApiKey();

            // Mappper.
            var mapper = new MapperConfiguration(cfg => cfg.AddProfile(typeof(DataMapperProfile)))
                         .CreateMapper();

            this.mapper = mapper;

            // Twitter Services.
            recentSearchService = new RecentSearchService(twitterApiKey);

            // Inmemory DB.
            var contextOptions = new DbContextOptionsBuilder <ToritoContext>()
                                 .UseInMemoryDatabase("ToritoDevInMemory")
                                 .Options;

            // Context and repositories.
            toritoContext = new ToritoContext(contextOptions);
            var isCreated = toritoContext.Database.EnsureCreated();

            tweetDbRepository     = new TweetDbRepository(toritoContext, mapper);
            tweetClientRepository = new TweetClientRepository(recentSearchService);
            cachedtweetService    = new CachedTweetService(tweetClientRepository, tweetDbRepository, this.mapper);

            // Cached task.
            cachedLast100TweetsTask = cachedtweetService.FetchAndUpdateLast100Tweets();
        }