Esempio n. 1
0
        /// <summary>
        /// Returns copy of cached object
        /// </summary>
        public void TestReturnCopyOfCachedOject()
        {
            CacheModel cacheModel = new CacheModel("test", typeof(LruCache).FullName, 60, 1, true);

            Order order = new Order(); 
            order.CardNumber = "CardNumber";
            order.Date = DateTime.Now;
            order.LineItemsCollection = new LineItemCollection();

            LineItem item = new LineItem();
            item.Code = "Code1";
            order.LineItemsCollection.Add(item);

            item = new LineItem();
            item.Code = "Code2";
            order.LineItemsCollection.Add(item);

            CacheKey key = new CacheKey();
            key.Update(order);

            int firstId = HashCodeProvider.GetIdentityHashCode(order);
            cacheModel[ key ] = order;

            Order order2 = cacheModel[ key ] as Order;
            int secondId = HashCodeProvider.GetIdentityHashCode(order2);
            Assert.AreNotEqual(firstId, secondId, "hasCode equal");

        }
Esempio n. 2
0
		public virtual void AddRange(LineItem[] value) 
		{
			for (int i = 0;	i < value.Length; i++) 
			{
				Add(value[i]);
			}
		}
Esempio n. 3
0
        /// <summary>
        /// Returns reference to same instance of cached object
        /// </summary>
        public void TestReturnInstanceOfCachedOject()
        {
            CacheModel cacheModel = new CacheModel("test", typeof(LruCache).FullName, 60, 1, false);

            //cacheModel.FlushInterval = interval;
            //cacheModel.IsReadOnly = true;
            //cacheModel.IsSerializable = false;

            Order order = new Order(); 
            order.CardNumber = "CardNumber";
            order.Date = DateTime.Now;
            order.LineItemsCollection = new LineItemCollection();
            LineItem item = new LineItem();
            item.Code = "Code1";
            order.LineItemsCollection.Add(item);
            item = new LineItem();
            item.Code = "Code2";
            order.LineItemsCollection.Add(item);

            CacheKey key = new CacheKey();
            key.Update(order);

            int firstId = HashCodeProvider.GetIdentityHashCode(order);
            cacheModel[ key ] = order;

            Order order2 = cacheModel[ key ] as Order;
            int secondId = HashCodeProvider.GetIdentityHashCode(order2);
            Assert.AreEqual(firstId, secondId, "hasCode different");
        }
Esempio n. 4
0
		public virtual void Remove(LineItem value) 
		{
			List.Remove(value);
		}
Esempio n. 5
0
		public virtual void Insert(int index, LineItem value) 
		{
			List.Insert(index, value);
		}
Esempio n. 6
0
		public virtual int IndexOf(LineItem value) 
		{
			return List.IndexOf(value);
		}
Esempio n. 7
0
		public virtual void CopyTo(LineItem[] array, int index) 
		{
			List.CopyTo(array, index);
		}
Esempio n. 8
0
		public virtual bool Contains(LineItem value) 
		{
			return List.Contains(value);
		}
Esempio n. 9
0
		public virtual int Add(LineItem value) 
		{
			return List.Add(value);
		}
Esempio n. 10
0
		public Order(int id, Account account, LineItem[] lineItemsArray)
		{
			_id = id;
			_account = account;
			_lineItemsArray = lineItemsArray;
		}
Esempio n. 11
0
        public void TestNullValueReplacementOnDecimal()
        {
            Account account = NewAccount6();

            dataMapper.Insert("InsertAccountViaParameterMap", account);

            Order order = new Order();
            order.Id = 99;
            order.CardExpiry = "09/11";
            order.Account = account;
            order.CardNumber = "154564656";
            order.CardType = "Visa";
            order.City = "Lyon";
            order.Date = System.DateTime.MinValue; //<-- null replacement for parameterMAp 
            order.PostalCode = "69004";
            order.Province = "Rhone";
            order.Street = "rue Durand";

            dataMapper.Insert("InsertOrderViaParameterMap", order);

            LineItem item = new LineItem();
            item.Id = 99;
            item.Code = "test";
            item.Price = -99.99m;//<-- null replacement for parameterMAp 
            item.Quantity = 99;
            item.Order = order;

            dataMapper.Insert("InsertLineItem", item);

            // Retrieve LineItem & test null replacement for resultMap 

            LineItem testItem = (LineItem)dataMapper.QueryForObject("GetSpecificLineItemWithNullReplacement", 99);

            Assert.IsNotNull(testItem);
            Assert.AreEqual(-77.77m, testItem.Price);
            Assert.AreEqual("test", testItem.Code);
        }
Esempio n. 12
0
        public void TestByteArrayMapping()
        {
            Account account = NewAccount6();

            dataMapper.Insert("InsertAccountViaParameterMap", account);

            Order order = new Order();
            order.Id = 99;
            order.CardExpiry = "09/11";
            order.Account = account;
            order.CardNumber = "154564656";
            order.CardType = "Visa";
            order.City = "Lyon";
            order.Date = System.DateTime.MinValue;
            order.PostalCode = "69004";
            order.Province = "Rhone";
            order.Street = "rue Durand";

            dataMapper.Insert("InsertOrderViaParameterMap", order);

            LineItem item = new LineItem();
            item.Id = 99;
            item.Code = "test";
            item.Price = -99.99m;
            item.Quantity = 99;
            item.Order = order;
            item.PictureData = new byte[] { 1, 2, 3 };

            // Check insert
            dataMapper.Insert("InsertLineItemWithPicture", item);

            // select
            LineItem loadItem = null;

            Hashtable param = new Hashtable();
            param.Add("LineItem_ID", 99);
            param.Add("Order_ID", 99);

            loadItem = dataMapper.QueryForObject("GetSpecificLineItemWithPicture", param) as LineItem;

            Assert.IsNotNull(loadItem.Id);
            Assert.IsNotNull(loadItem.PictureData);
            Assert.AreEqual(item.PictureData, loadItem.PictureData);
        }
Esempio n. 13
0
        public void TestInsertPreKey()
        {
            LineItem item = new LineItem();

            item.Id = 10;
            item.Code = "blah";
            item.Order = new Order();
            item.Order.Id = 9;
            item.Price = 44.00m;
            item.Quantity = 1;

            object key = dataMapper.Insert("InsertLineItemPreKey", item);

            Assert.AreEqual(99, key);
            Assert.AreEqual(99, item.Id);

            Hashtable param = new Hashtable();
            param.Add("Order_ID", 9);
            param.Add("LineItem_ID", 99);

            LineItem testItem = (LineItem)dataMapper.QueryForObject("GetSpecificLineItem", param);

            Assert.IsNotNull(testItem);
            Assert.AreEqual(99, testItem.Id);
        }
Esempio n. 14
0
        public void TestOrderLineItemGroupBy()
        {
            InitScript(sessionFactory.DataSource, scriptDirectory + "petstore-drop.sql");
            InitScript(sessionFactory.DataSource, scriptDirectory + "account-init.sql");
            InitScript(sessionFactory.DataSource, scriptDirectory + "order-init.sql");
            InitScript(sessionFactory.DataSource, scriptDirectory + "line-item-init.sql");

            Order order = new Order();
            order.Id = 11;
            LineItem item = new LineItem();
            item.Id = 10;
            item.Code = "blah";
            item.Price = 44.00m;
            item.Quantity = 1;
            item.Order = order;

            dataMapper.Insert("InsertLineItemPostKey", item);

            
            IList list = dataMapper.QueryForList("GetOrderLineItem", null);

            Assert.AreEqual(11, list.Count);
            
            order = (Order)list[0];
            Assert.AreEqual(3, order.LineItemsIList.Count);
            Assert.IsNotNull(order.Account);
            AssertAccount1(order.Account);

            order = (Order)list[10];
            Assert.AreEqual(1, order.LineItemsIList.Count);
            Assert.IsNull(order.Account);
        }