コード例 #1
0
        public void Scenario2_existing_product_type()
        {
            var gameSimContext = new Mock<IGameSimContext>();

            var domainProductType = new ProductType
            {
                Id = 1
            };
            var pDs = new List<ProductType>()
            {
                domainProductType
            };
            var productTypes = new FakeDbSet<ProductType>(pDs);
            gameSimContext.Setup(x => x.ProductTypes).Returns(productTypes);
            var controller = new ProductTypeController(gameSimContext.Object);

            var productTypeToSave = new WebApi.Models.ProductType
            {
                Id = 1,
                Name = "test",
                ManufacturerTypeId = 1,
                Products = new List<Product>(),
                RequiredProducts = new List<Product>(),
                TimeToManufacture = 10,
                SalePriceInDollars = 10
            };
            var ret = controller.Post(productTypeToSave);
            productTypes.Count().ShouldEqual(1);
            ret.Id.ShouldEqual(1);
            gameSimContext.Verify(x=>x.SetValues(It.IsAny<ProductType>(), It.IsAny<ProductType>()));
        }
コード例 #2
0
ファイル: SandBox.cs プロジェクト: cberberian/GameSim
        public void Lambda1()
        {
            var pds = new ProductType[]
            {
                new ProductType
                {
                    Id = 2
                },
                new ProductType
                {
                    Id = 1
                },
                new ProductType
                {
                    Id = 4
                },
                new ProductType
                {
                    Id=3
                }
            };

            //Left of x => x.Id
            var pe = Expression.Parameter(typeof (ProductType), "productType");
            //
            var exp = Expression.Lambda<Func<ProductType, int>>(Expression.Property(pe, "Id"), pe);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: cberberian/GameSim
        static void Main(string[] args)
        {
            App_Start.EntityFrameworkProfilerBootstrapper.PreStart();

            using (var db = new GameSimContext())
            {
                var productType = new ProductType
                {
                    Name = "test"
                };
                db.ProductTypes.Add(productType);
                db.SaveChanges();
            }
        }
コード例 #4
0
        public void Scenario3_required_product_added()
        {
            var gameSimContext = new Mock<IGameSimContext>();

            var domainProductType = new ProductType
            {
                Id = 1,
                RequiredProducts = new List<Domain.Product>()
            };
            var pDs = new List<ProductType>()
            {
                domainProductType
            };
            var productTypes = new FakeDbSet<ProductType>(pDs);
            gameSimContext.Setup(x => x.ProductTypes).Returns(productTypes);
            var controller = new ProductTypeController(gameSimContext.Object);

            var productTypeToSave = new WebApi.Models.ProductType
            {
                Id = 1,
                Name = "test",
                ManufacturerTypeId = 1,
                Products = new List<Product>(),
                RequiredProducts = new List<Product>
                {
                    new Product
                    {
                        Quantity = 1,
                        ProductTypeId = 2
                    }
                },
                TimeToManufacture = 10,
                SalePriceInDollars = 10
            };
            var ret = controller.Post(productTypeToSave);
            productTypes.Count().ShouldEqual(1);
            ret.Id.ShouldEqual(1);
            gameSimContext.Verify(x=>x.SetValues(It.IsAny<ProductType>(), It.IsAny<ProductType>()));
            domainProductType.RequiredProducts.Any().ShouldBeTrue();
            domainProductType.RequiredProducts.First().Quantity.ShouldEqual(1);
            domainProductType.RequiredProducts.First().ProductTypeId.ShouldEqual(2);
        }
コード例 #5
0
 public void SetValues(ProductType dest, ProductType chng)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
 public void Add(ProductType entity)
 {
     throw new NotImplementedException();
 }