コード例 #1
0
        public ProductService InitialiseProductsServiceWithSampleData()
        {
            var context = GetRealDbProductContext();

            context.Database.EnsureDeleted();
            context.SaveChanges();

            ProductService ps = new ProductsService.ProductService(context);

            Task.Run(async() =>
            {
                await ps.InitialiseWithSeedData();
            }).GetAwaiter().GetResult();
            ps.Dispose();
            context = GetRealDbProductContext();
            ps      = new ProductsService.ProductService(context);
            return(ps);
        }
コード例 #2
0
        public void SimpleDatabaseInitialisation()
        {
            var context = GetRealDbProductContext();

            context.Database.EnsureDeleted();
            context.SaveChanges();

            ProductsService.ProductService ps = new ProductsService.ProductService(context);
            Task.Run(async() =>
            {
                await ps.Initialise();
            }).GetAwaiter().GetResult();
            var products = Task.Run(async() =>
            {
                return(await ps.GetProducts());
            }).GetAwaiter().GetResult();

            Assert.True(products.Count() == 0);
        }