예제 #1
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = TestStartup.ConfigureServices();

            voteConstructor = serviceProvider.GetRequiredService <VoteConstructor>();
            voteCounter     = serviceProvider.GetRequiredService <IVoteCounter>();
        }
예제 #2
0
        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();
        }
예제 #3
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = TestStartup.ConfigureServices();
            var hash = serviceProvider.GetRequiredService <IHash>();

            Agnostic.HashStringsUsing(hash.HashFunction);
        }
예제 #4
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = TestStartup.ConfigureServices();

            pageProvider        = serviceProvider.GetRequiredService <IPageProvider>();
            forumAdapterFactory = serviceProvider.GetRequiredService <ForumAdapterFactory>();
        }
예제 #5
0
        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);
        }
예제 #6
0
        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)));
        }
예제 #7
0
        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();
        }
예제 #8
0
        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();
        }
예제 #9
0
        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));
        }
예제 #11
0
        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)));
        }
예제 #12
0
        /// <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);
        }
예제 #13
0
        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();
        }
예제 #14
0
        // 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();
        }
예제 #15
0
 public static void ClassInit(TestContext context)
 {
     serviceProvider = TestStartup.ConfigureServices();
 }
예제 #16
0
 /// <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;
 }