public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); voteConstructor = serviceProvider.GetRequiredService <VoteConstructor>(); voteCounter = serviceProvider.GetRequiredService <IVoteCounter>(); }
public void Is_CampaignRepository_CreateCampaign_Return_CampaignInfo(string name, string code, int duration, int limit, int tsCount, int expectedResult) { TestStartup.ConfigureServices(); var repository = TestStartup.ServiceProvider.GetService <ICampaignRepository>(); var campaign = new Campaign { Name = name, ProductCode = code, Duration = duration, Limit = limit, TargetSalesCount = tsCount, Active = true, Turnover = 0, StartDate = DateTime.Now, EndDate = DateTime.Now.AddHours(6), TotalSales = 0, AverageItemPrice = 0, CampaignProductPrice = 0 }; var result = repository.AddCampaign(campaign); Assert.NotEqual(expectedResult, result.Id); TestStartup.DisposeServices(); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); var hash = serviceProvider.GetRequiredService <IHash>(); Agnostic.HashStringsUsing(hash.HashFunction); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); pageProvider = serviceProvider.GetRequiredService <IPageProvider>(); forumAdapterFactory = serviceProvider.GetRequiredService <ForumAdapterFactory>(); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); VoteLine voteLine = new VoteLine("", "X", "", "A sample vote line", MarkerType.Vote, 100); vote = new VoteLineBlock(voteLine); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); agnostic = serviceProvider.GetRequiredService <IAgnostic>(); IQuest quest = new Quest(); agnostic.ComparisonPropertyChanged(quest, new PropertyChangedEventArgs(nameof(quest.CaseIsSignificant))); }
public void Is_CampaignService_CreateCampaign_Return_CampaignInfo(string command, string expectedResult) { TestStartup.ConfigureServices(); var service = TestStartup.ServiceProvider.GetService <ICampaignService>(); var result = service.CreateCampaign(command.Split(' ')); Assert.NotEqual(expectedResult, result); TestStartup.DisposeServices(); }
public void Is_ProductService_CreateProduct_Return_ProductInfo(string command, string expectedResult) { TestStartup.ConfigureServices(); var service = TestStartup.ServiceProvider.GetService <IProductService>(); var result = service.CreateProduct(command.Split(' ')); Assert.Equal(expectedResult, result); TestStartup.DisposeServices(); }
private HttpContext CreateTestHttpContext() { var ctx = new DefaultHttpContext(); var startup = new TestStartup(); var sc = new ServiceCollection(); startup.ConfigureServices(sc); ctx.RequestServices = sc.BuildServiceProvider(); return(ctx); }
private TestServer CreateTestServer() { var hostBuilder = new WebHostBuilder().ConfigureServices(services => _startup.ConfigureServices(services)) .Configure(app => { _app = app; _hostingEnv = app.ApplicationServices.GetRequiredService <IHostingEnvironment>(); _startup.Configure(app, _hostingEnv); }); return(new TestServer(hostBuilder)); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); voteCounter = serviceProvider.GetRequiredService <IVoteCounter>(); tally = serviceProvider.GetRequiredService <Tally>(); voteConstructor = serviceProvider.GetRequiredService <VoteConstructor>(); agnostic = serviceProvider.GetRequiredService <IAgnostic>(); IQuest quest = new Quest(); agnostic.ComparisonPropertyChanged(quest, new System.ComponentModel.PropertyChangedEventArgs(nameof(quest.CaseIsSignificant))); }
/// <summary> /// Gets the default service provider /// </summary> /// <returns></returns> private IServiceProvider GetDefaultServiceProvider() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Build(); var startup = new TestStartup(configuration); var serviceProvicer = startup.ConfigureServices(new ServiceCollection()); return(serviceProvicer); }
public void Is_ProductRepository_CreateProduct_Return_ProductInfo(string code, int price, int stock, int expectedResult) { TestStartup.ConfigureServices(); var repository = TestStartup.ServiceProvider.GetService <IProductRepository>(); var product = new Product { ProductCode = code, Price = price, Stock = stock }; var result = repository.AddProduct(product); Assert.NotEqual(expectedResult, result.Id); TestStartup.DisposeServices(); }
// Use Respawn checkpoints to store database clean states if testing with a persistent/production-like database //private static readonly Checkpoint _checkpoint; static SliceFixture() { _host = A.Fake <IHostingEnvironment>(); A.CallTo(() => _host.ContentRootPath).Returns(Directory.GetCurrentDirectory()); var startup = new TestStartup(new ConfigurationBuilder().Build()); _configuration = Startup.Configuration; var services = new ServiceCollection(); startup.ConfigureServices(services); _rootContainer = services.BuildServiceProvider(); _scopeFactory = _rootContainer.GetService <IServiceScopeFactory>(); //_checkpoint = new Checkpoint(); }
public static void ClassInit(TestContext context) { serviceProvider = TestStartup.ConfigureServices(); }
/// <summary> /// General initialization for the test, in addition to whatever the /// implmentation class does. /// </summary> public void Init() { serviceProvider = TestStartup.ConfigureServices(); pageProvider = serviceProvider.GetRequiredService <IPageProvider>(); quest.PropertyChanged += IQuest_PropertyChanged; }