public async Task Setup() { Action <IServiceCollection> actions = (sc) => { sc.ReplaceTransient <IDbContextFactory <PersonalCommonLegacyContext>, InMemoryPersonalCommonLegacyContextFactory>(); sc.ReplaceTransient <IDbContextFactory <PersonalLegacyContext>, InMemoryPersonalLegacyContextFactory>(); var usercontext = new StaticUserContext(new UserContext { UserId = _userId }); sc.Remove <ICurrentUserContext>(); sc.AddScoped <ICurrentUserContext>(i => usercontext); }; _testServer = new TestServerBuilder() .WithPostConfigureCollection(actions) .Build <Startup>(); _client = _testServer.CreateClientWithJwtToken(_customerId, _userId); var fakeCustomerIdService = A.Fake <ICustomerIdService>(); A.CallTo(() => fakeCustomerIdService.GetCustomerIdNotNull()).Returns(_customerId); var personalLegacyFactory = new InMemoryPersonalLegacyContextFactory(fakeCustomerIdService); _personalLegacyDb = await personalLegacyFactory.CreateDbContext(); var personalCommonLegacyFactory = _testServer.Host.Services.GetService <IDbContextFactory <PersonalCommonLegacyContext> >(); _personalCommonLegacyDb = await personalCommonLegacyFactory.CreateDbContext(); }
public async Task SetUp() { _testServer = new TestServerBuilder() .WithPostConfigureCollection((sc) => { sc.ReplaceTransient <IDbContextFactory <PersonalCommonLegacyContext>, InMemoryPersonalCommonLegacyContextFactory>(); var usercontext = new StaticUserContext(new UserContext { UserId = _userId }); sc.Remove <ICurrentUserContext>(); sc.AddScoped <ICurrentUserContext>(i => usercontext); }) .Build <Startup>(); _client = _testServer.CreateClientWithJwtToken(_customerId, _userId); var personalCommonLegacyFactory = _testServer.Host.Services.GetService <IDbContextFactory <PersonalCommonLegacyContext> >(); _personalCommonLegacyDb = await personalCommonLegacyFactory.CreateDbContext(); }