public virtual void TestSetup()
        {
            HttpClient httpClient;
            var        databaseRoot = new InMemoryDatabaseRoot();

            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase(DatabaseName, databaseRoot)
                             .Options;

            var webAppFactory = new InMemoryFactory <FakeResponseServer.Startup>(DatabaseName, databaseRoot);

            httpClient = webAppFactory.CreateClient(FakeServerAddress);

            externalAPICaller = new ExternalAPICaller(httpClient);

            FakeDataRetrievalSourceFactory = () => new FakeDataRetrievalSource(externalAPICaller, FakeServerAddress);
        }
        public static void TestSetup(IObjectContainer objectContainer)
        {
            HttpClient httpClient;

            databaseRoot   = new InMemoryDatabaseRoot();
            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase(DatabaseName, databaseRoot).Options;
            var webAppFactory = new InMemoryFactory <FakeResponseServer.Startup>(DatabaseName, databaseRoot);

            httpClient = webAppFactory.CreateClient("http://localhost:2222");

            var spotifyClient = new ExternalAPICaller(httpClient);

            var dataSource = new DataPort(contextOptions, spotifyClient);

            clientDriver = new ApiClientDriver();
            clientDriver.SetUp(dataSource.ExternalAPIGateway);

            objectContainer.RegisterInstanceAs <IClientDriver>(clientDriver);
            objectContainer.RegisterInstanceAs(dataSource);

            Thread.Sleep(TimeSpan.FromSeconds(1));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataPort"/> class.
 /// </summary>
 /// <param name="contextOptions">Fake backend database context options. </param>
 /// <param name="spotifyClient">Fake spotify client to make API calls with. </param>
 public DataPort(DbContextOptions <DataRetrievalContext> contextOptions, ExternalAPICaller externalAPICaller)
 {
     this.contextOptions    = contextOptions;
     this.externalAPICaller = externalAPICaller;
 }