Esempio n. 1
0
        public virtual ProductDistributor InsertProductDistributor(ProductDistributor entity)
        {
            ProductDistributor other = new ProductDistributor();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into ProductDistributor ( [ProductID]
				,[DistributorID]
				,[DisplayOrder]
				,[CreatedOn] )
				Values
				( @ProductID
				, @DistributorID
				, @DisplayOrder
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@ProductID", entity.ProductId)
                    , new SqlParameter("@DistributorID", entity.DistributorId)
                    , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetProductDistributor(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Esempio n. 2
0
        public virtual ProductDistributor UpdateProductDistributor(ProductDistributor entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            ProductDistributor other = GetProductDistributor(entity.ProductId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update ProductDistributor set  [DistributorID]=@DistributorID
							, [DisplayOrder]=@DisplayOrder
							, [CreatedOn]=@CreatedOn 
							 where ProductID=@ProductID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@ProductID", entity.ProductId)
                , new SqlParameter("@DistributorID", entity.DistributorId)
                , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetProductDistributor(entity.ProductId));
        }
Esempio n. 3
0
        public void TestProductNotAvailableWithElements()
        {
            ProductDistributor producer    = new ProductDistributor();
            Product            testProduct = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);

            Assert.IsFalse(producer.ProductAvailable("TestGame"));
        }
Esempio n. 4
0
        public void TestGetProductGamesFound()
        {
            ProductDistributor producer    = new ProductDistributor();
            Product            testProduct = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);

            Assert.IsNotNull(producer.GetProduct(testProduct.Game.GetName()));
        }
Esempio n. 5
0
        public void TestGetAvailableGamesNonEmptyList()
        {
            ProductDistributor producer    = new ProductDistributor();
            Product            testProduct = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);

            Assert.IsNotEmpty(producer.GetAvailableGames());
        }
Esempio n. 6
0
        public void TestProductAvailable()
        {
            ProductDistributor producer    = new ProductDistributor();
            Product            testProduct = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);

            Assert.IsTrue(producer.ProductAvailable(testProduct.Game.GetName()));
        }
Esempio n. 7
0
        public void TestAddGame()
        {
            ProductDistributor producer    = new ProductDistributor();
            Product            testProduct = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);
            int testAvailableGames = producer.GetAvailableGames().Count;

            Assert.AreEqual(1, testAvailableGames);
        }
        public void ProductIdTest()
        {
            // Test Variable declaration
            Guid expectedValueId = Guid.NewGuid();
            ProductDistributor productDistributor = new ProductDistributor(expectedValueId);

            // Assertions
            Assert.IsNotNull(productDistributor.ProductId);
            Assert.AreEqual(expectedValueId, productDistributor.ProductId);
            Assert.AreNotSame(expectedValueId, productDistributor.ProductId);
        }
        public void CreatedOnTest()
        {
            // Test Variable declaration
            DateTime expectedValueDate = DateTime.Now;
            ProductDistributor productDistributor = new ProductDistributor(Guid.NewGuid()) { CreatedOn = expectedValueDate };
            DateTime createdOn = productDistributor.CreatedOn;

            // Assertions
            Assert.IsNotNull(productDistributor.CreatedOn);
            Assert.AreEqual(expectedValueDate, productDistributor.CreatedOn);
        }
Esempio n. 10
0
        public virtual ProductDistributor ProductDistributorFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            ProductDistributor entity = new ProductDistributor();

            entity.ProductId     = (System.Int32)dr["ProductID"];
            entity.DistributorId = (System.Int32)dr["DistributorID"];
            entity.DisplayOrder  = (System.Int32)dr["DisplayOrder"];
            entity.CreatedOn     = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
Esempio n. 11
0
        public void TestAddAndRemoveMoreGames()
        {
            ProductDistributor producer     = new ProductDistributor();
            Product            testProduct  = ProductFlyweightFactory.MakeProduct();
            Product            testProduct2 = ProductFlyweightFactory.MakeProduct();
            Product            testProduct3 = ProductFlyweightFactory.MakeProduct();

            producer.AddProduct(testProduct);
            producer.AddProduct(testProduct2);
            producer.AddProduct(testProduct3);

            producer.RemoveProduct(testProduct2);

            int testAvailableGames = producer.GetAvailableGames().Count;

            Assert.AreEqual(2, testAvailableGames);
        }
Esempio n. 12
0
 public void AddToProductDistributor(ProductDistributor ProductDistributor)
 {
     this.ProductDistributor.Add(ProductDistributor);
 }
Esempio n. 13
0
 public virtual ProductDistributor DeleteProductDistributor(ProductDistributor entity)
 {
     this.DeleteProductDistributor(entity.ProductId);
     return(entity);
 }
 public ProductDistributor UpdateProductDistributor(ProductDistributor entity)
 {
     return(_iProductDistributorRepository.UpdateProductDistributor(entity));
 }
 public ProductDistributor InsertProductDistributor(ProductDistributor entity)
 {
     return(_iProductDistributorRepository.InsertProductDistributor(entity));
 }
Esempio n. 16
0
        public void TestGetAvailbleGamesEmtyList()
        {
            ProductDistributor producer = new ProductDistributor();

            Assert.IsEmpty(producer.GetAvailableGames());
        }
Esempio n. 17
0
        public void TestProductNotAvailableNonElements()
        {
            ProductDistributor producer = new ProductDistributor();

            Assert.IsFalse(producer.ProductAvailable("Escape from Tarkov"));
        }
Esempio n. 18
0
        public void TestGetProductNoGamesFound()
        {
            ProductDistributor producer = new ProductDistributor();

            Assert.IsNull(producer.GetProduct("Call of Duty"));
        }