コード例 #1
0
        public void IntsToEntities()
        {
            WindsorRegistrar.RegisterSingleton(typeof(IRepo <>), typeof(Repo <>));
            WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory));
            using (var scope = new TransactionScope())
            {
                var repo     = new Repo <cm.Product>(new DbContextFactory());
                var product1 = new cm.Product {
                    Name = "a"
                };
                var product2 = new cm.Product {
                    Name = "b"
                };

                product1 = repo.Insert(product1);
                product2 = repo.Insert(product2);
                repo.Save();

                var promotionInput = new PromotionInput {
                    Products = new List <int> {
                        product1.Id, product2.Id
                    }
                };
                var promotion = new cm.Promotion();

                promotion.InjectFrom <IntsToEntities>(promotionInput);

                Assert.IsNotNull(promotion.Products);
                Assert.AreEqual(2, promotion.Products.Count);
                Assert.AreEqual(product1.Id, promotion.Products.First().Id);
            }
        }
コード例 #2
0
        public void IntsToEntities()
        {
            WindsorRegistrar.RegisterSingleton(typeof(IRepo<>), typeof(Repo<>));
            WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory));
            using (var scope = new TransactionScope())
            {
                var repo = new Repo<cm.Product>(new DbContextFactory());
                var product1 = new cm.Product { Name = "a" };
                var product2 = new cm.Product { Name = "b" };

                product1 = repo.Insert(product1);
                product2 = repo.Insert(product2);
                repo.Save();

                var promotionInput = new PromotionInput { Products = new List<int> { product1.Id, product2.Id } };
                var promotion = new cm.Promotion();

                promotion.InjectFrom<IntsToEntities>(promotionInput);

                Assert.IsNotNull(promotion.Products);
                Assert.AreEqual(2, promotion.Products.Count);
                Assert.AreEqual(product1.Id, promotion.Products.First().Id);
            }
        }