public void Scenario2_new_product_type()
        {
            var gameSimContext = new Mock<IGameSimContext>();

            var pDs = GetExistingDomainProductTypes();
            var productTypes = new FakeDbSet<ProductType>(pDs);
            var products = new FakeDbSet<Domain.Product>();
            gameSimContext.Setup(x => x.ProductTypes).Returns(productTypes);
            gameSimContext.Setup(x => x.Products).Returns(products);
            var controller = new ProductTypeController(gameSimContext.Object);

            var productTypeToSave = new WebApi.Models.ProductType
            {
                Name = "test",
                RequiredProducts = new List<Product>
                {
                    new Product
                    {
                        ProductTypeId = 1
                    }
                }
            };
            var ret = controller.Post(productTypeToSave);
            productTypes.Count().ShouldEqual(3);
            products.Count().ShouldEqual(1);
            var productType = productTypes.ToArray()[1];
            productType.Id.ShouldEqual(3);
            productType.RequiredProducts.First().RequiredByTypeId.ShouldEqual(1);
            productType.RequiredProducts.First().ProductTypeId.ShouldEqual(2);
            productType.RequiredProducts.First().Quantity.ShouldEqual(1);
            ret.Id.ShouldEqual(2);
        }
        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>()));
        }
        public void Scenario1_null_request()
        {
            var gameSimContext = new Mock<IGameSimContext>();
            var controller = new ProductTypeController(gameSimContext.Object);

            var ret = controller.Post(null);
            ret.ShouldBeNull();
        }
        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);
        }