public DomainModelServiceTest(NorthwindDbContextFixture fixture)
        {
            _customers  = Factory.Customers();
            _categories = Factory.Categories();
            _products   = Factory.Products();
            _fixture    = fixture;
            _fixture.Initialize(true, () =>
            {
                _fixture.Context.Customers.AddRange(_customers);
                _fixture.Context.Categories.AddRange(_categories);
                _fixture.Context.Products.AddRange(_products);
                _fixture.Context.SaveChanges();
            });

            var mapperConfiguration = new MapperConfiguration(config =>
            {
                config.CreateMap <Product, ProductDomainModel>()
                .ForMember(dto => dto.Category, conf => conf.MapFrom(ol => ol.Category)).ReverseMap();

                config.CreateMap <Category, CategoryDomainModel>()
                .ForMember(dto => dto.Products, conf => conf.MapFrom(ol => ol.Products));

                config.CreateMap <Customer, CustomerDomainModel>().ReverseMap();
            });

            _mapper = mapperConfiguration.CreateMapper();
        }
Ejemplo n.º 2
0
        public TrackableRepositoryTest(NorthwindDbContextFixture fixture)
        {
            var categories = new List <Category>
            {
                new Category {
                    CategoryId = 1, CategoryName = "Beverages"
                },
            };
            var products = new List <Product>
            {
                new Product {
                    ProductId = 1, ProductName = "Product 1", UnitPrice = 10, CategoryId = 1
                },
                new Product {
                    ProductId = 2, ProductName = "Product 2", UnitPrice = 20, CategoryId = 1
                },
                new Product {
                    ProductId = 3, ProductName = "Product 3", UnitPrice = 30, CategoryId = 1
                },
            };
            var customer = new Customer
            {
                CustomerId  = "ALFKI",
                ContactName = "Maria Anders"
            };
            var order = new Order
            {
                OrderId      = 1,
                OrderDate    = DateTime.Today,
                CustomerId   = "ALFKI",
                Customer     = customer,
                OrderDetails = new List <OrderDetail>
                {
                    new OrderDetail {
                        OrderDetailId = 1, OrderId = 1, ProductId = 1, Product = products[0], UnitPrice = 10, Quantity = 100
                    },
                    new OrderDetail {
                        OrderDetailId = 2, OrderId = 1, ProductId = 2, Product = products[1], UnitPrice = 20, Quantity = 200
                    },
                    new OrderDetail {
                        OrderDetailId = 3, OrderId = 1, ProductId = 3, Product = products[2], UnitPrice = 30, Quantity = 300
                    },
                }
            };

            _fixture = fixture;
            _fixture.Initialize(true, () =>
            {
                _fixture.Context.Categories.AddRange(categories);
                _fixture.Context.Products.AddRange(products);
                _fixture.Context.Customers.Add(customer);
                _fixture.Context.Orders.Add(order);
                _fixture.Context.SaveChanges();
            });

            _unitOfWork = new UnitOfWork(_fixture.Context);
        }
Ejemplo n.º 3
0
 public RepositorySqlTest(NorthwindDbContextFixture fixture)
 {
     _fixture = fixture;
     _fixture.Initialize(true, () =>
     {
         _fixture.Context.Categories.AddRange(_categories);
         _fixture.Context.Products.AddRange(_products);
         _fixture.Context.SaveChangesAsync();
     });
 }
Ejemplo n.º 4
0
        public TrackableRepositoryTest(NorthwindDbContextFixture fixture)
        {
            _fixture = fixture;
            _fixture.Initialize(true, () =>
            {
                _fixture.Context.Categories.AddRange(Factory.Categories());
                _fixture.Context.Products.AddRange(Factory.Products());
                _fixture.Context.Customers.AddRange(Factory.Customers());
                _fixture.Context.Orders.AddRange(Factory.Orders());
                _fixture.Context.OrderDetails.AddRange(Factory.OrderDetails());
                _fixture.Context.SaveChanges();
            });

            _unitOfWork = new UnitOfWork(_fixture.Context);
        }
        public DomainServiceQueryableTests(NorthwindDbContextFixture fixture)
        {
            var customers = Factory.Customers();

            _fixture = fixture;
            _fixture.Initialize(true, () =>
            {
                _fixture.Context.Customers.AddRange(customers);
                _fixture.Context.SaveChanges();
            });

            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <CustomerDomainModel, Customer>();
                cfg.CreateMap <Customer, CustomerDomainModel>();
            });

            _mapper = config.CreateMapper();
        }
Ejemplo n.º 6
0
        public QueryIncludeTest(NorthwindDbContextFixture fixture)
        {
            var categories   = Factory.Categories();
            var products     = Factory.Products();
            var orders       = Factory.Orders();
            var customers    = Factory.Customers();
            var orderDetails = Factory.OrderDetails();

            _fixture = fixture;
            _fixture.Initialize(false, () =>
            {
                EnsureEntities(_fixture.Context, categories);
                EnsureEntities(_fixture.Context, products);
                EnsureEntities(_fixture.Context, customers);
                EnsureEntities(_fixture.Context, orders);
                EnsureEntities(_fixture.Context, orderDetails);
            });
        }
Ejemplo n.º 7
0
        public ServiceTest(NorthwindDbContextFixture fixture)
        {
            _orders        = Factory.Orders();
            _products      = Factory.Products();
            _categories    = Factory.Categories();
            _customers     = Factory.Customers();
            _ordersDetails = Factory.OrderDetails();

            _fixture = fixture;
            _fixture.Initialize(true, () =>
            {
                _fixture.Context.Categories.AddRange(_categories);
                _fixture.Context.Products.AddRange(_products);
                _fixture.Context.Customers.AddRange(_customers);
                _fixture.Context.Orders.AddRange(_orders);
                _fixture.Context.OrderDetails.AddRange(_ordersDetails);
                _fixture.Context.SaveChanges();
            });
        }
 public CustomTemplatesDirTests(NorthwindDbContextFixture fixture)
 {
     Fixture = fixture;
     Fixture.Initialize();
 }
        public HbsTypeScriptScaffoldingGeneratorTests(NorthwindDbContextFixture fixture)
        {
            Fixture = fixture;
            Fixture.Initialize(useInMemory: false);

            var projectRootDir = Path.Combine("..", "..", "..", "..", "..");

            var contextTemplatesVirtualPath =
                $"{Constants.Templates.CodeTemplatesFolder}/{Constants.Templates.TypeScriptTemplateDirectories.ContextFolder}";
            var contextPartialsVirtualPath = contextTemplatesVirtualPath + $"/{Constants.Templates.PartialsFolder}";
            var contextTemplatesPath       = Path.Combine(projectRootDir, "src", Constants.Templates.ProjectFolder,
                                                          Constants.Templates.CodeTemplatesFolder, Constants.Templates.TypeScriptTemplateDirectories.ContextFolder);
            var contextPartialTemplatesPath = Path.Combine(contextTemplatesPath, Constants.Templates.PartialsFolder);

            var entityTemplatesVirtualPath =
                $"{Constants.Templates.CodeTemplatesFolder}/{Constants.Templates.TypeScriptTemplateDirectories.EntityTypeFolder}";
            var entityPartialsVirtualPath = entityTemplatesVirtualPath + $"/{Constants.Templates.PartialsFolder}";
            var entityTemplatesPath       = Path.Combine(projectRootDir, "src", Constants.Templates.ProjectFolder,
                                                         Constants.Templates.CodeTemplatesFolder, Constants.Templates.TypeScriptTemplateDirectories.EntityTypeFolder);
            var entityPartialTemplatesPath = Path.Combine(entityTemplatesPath, Constants.Templates.PartialsFolder);

            ContextClassTemplate = new InputFile
            {
                Directory = contextTemplatesVirtualPath,
                File      = Constants.Templates.ContextClassFile,
                Contents  = File.ReadAllText(Path.Combine(contextTemplatesPath, Constants.Templates.ContextClassFile))
            };
            ContextImportsTemplate = new InputFile
            {
                Directory = contextPartialsVirtualPath,
                File      = Constants.Templates.ContextImportsFile,
                Contents  = File.ReadAllText(Path.Combine(contextPartialTemplatesPath, Constants.Templates.ContextImportsFile))
            };
            ContextCtorTemplate = new InputFile
            {
                Directory = contextPartialsVirtualPath,
                File      = Constants.Templates.ContextCtorFile,
                Contents  = File.ReadAllText(Path.Combine(contextPartialTemplatesPath, Constants.Templates.ContextCtorFile))
            };
            ContextDbSetsTemplate = new InputFile
            {
                Directory = contextPartialsVirtualPath,
                File      = Constants.Templates.ContextDbSetsFile,
                Contents  = File.ReadAllText(Path.Combine(contextPartialTemplatesPath, Constants.Templates.ContextDbSetsFile))
            };

            EntityClassTemplate = new InputFile
            {
                Directory = entityTemplatesVirtualPath,
                File      = Constants.Templates.EntityClassFile,
                Contents  = File.ReadAllText(Path.Combine(entityTemplatesPath, Constants.Templates.EntityClassFile))
            };
            EntityImportsTemplate = new InputFile
            {
                Directory = entityPartialsVirtualPath,
                File      = Constants.Templates.EntityImportsFile,
                Contents  = File.ReadAllText(Path.Combine(entityPartialTemplatesPath, Constants.Templates.EntityImportsFile))
            };
            EntityCtorTemplate = new InputFile
            {
                Directory = entityPartialsVirtualPath,
                File      = Constants.Templates.EntityCtorFile,
                Contents  = File.ReadAllText(Path.Combine(entityPartialTemplatesPath, Constants.Templates.EntityCtorFile))
            };
            EntityPropertiesTemplate = new InputFile
            {
                Directory = entityPartialsVirtualPath,
                File      = Constants.Templates.EntityPropertiesFile,
                Contents  = File.ReadAllText(Path.Combine(entityPartialTemplatesPath, Constants.Templates.EntityPropertiesFile))
            };
        }
 public NavigationExtensionsTests(NorthwindDbContextFixture fixture)
 {
     _fixture = fixture;
     _fixture.Initialize();
 }
 public UnitOfWorkTest(NorthwindDbContextFixture fixture)
 {
     _fixture = fixture;
     _fixture.Initialize();
 }
Ejemplo n.º 12
0
 public LoadRelatedEntitiesTests(NorthwindDbContextFixture fixture)
 {
     _fixture = fixture;
     _fixture.Initialize(false, EnsureSeedData);
 }