Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public void NullablesToNormal()
        {
            var promotionInput = new PromotionInput {};
            var promotion = new cm.Promotion();

            promotion.InjectFrom<NullablesToNormal>(promotionInput);
            Assert.AreEqual(default(DateTime), promotion.Start);
        }
Exemplo n.º 3
0
        public void NullablesToNormal()
        {
            var promotionInput = new PromotionInput {
            };
            var promotion      = new cm.Promotion();

            promotion.InjectFrom <NullablesToNormal>(promotionInput);
            Assert.AreEqual(default(DateTime), promotion.Start);
        }
Exemplo n.º 4
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);
            }
        }