Example #1
0
    public Reads() {
      var list1 = new BiggyList<Product>();
      test1 = new Product { Sku = "XXX", Name = "Steve's Stuffs", Price = 100.00M };
      list1.Add(test1);
      list1.Save();

      //this should read from the file
      _products = new BiggyList<Product>();
    }
Example #2
0
    public Writes() {
      //clear out the list
      _products = new BiggyList<Product>();

      //empty the db
      _products.ClearAndSave();


      test1 = new Product { Sku = "XXX", Name = "Steve's Stuffs", Price = 100.00M };
      _products.Saved += _products_Saved;
      _products.ItemAdded += _products_ItemAdded;
      _products.Add(test1);
      _products.Save();
    }
Example #3
0
    public void WontDuplicate() {
      _products.ClearAndSave();
      _products.Add(test1);

      Assert.True(_products.Count == 1);

      //Product has Equals set to compare SKU
      var test2 = new Product { Sku = "XXX", Name = "Other Kine Stuffs", Price = 100.00M };
      _products.Add(test2);

      Assert.True(_products.Count == 1);
      //now be sure it's the updated product

      Assert.True(_products.First().Name == "Other Kine Stuffs");
    }
		public void WhenPostNew_ThenSavesAndRetrievesId()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var product = new Product { Owner = new User { Id = 1, Name = "kzu" } };

				var saved = client.Post(product);

				Assert.Equal(4, saved.Id);

				Assert.Equal(saved.Owner.Id, product.Owner.Id);
				Assert.Equal(saved.Owner.Name, product.Owner.Name);
			}
		}
 public void Init()
 {
     _product = new Product()
     {
         Name = "ধান",
         Category = "শস্য",
         Subcategory = "দানাদার",
         FarmerId = 1,
         ExpiryDate = "11/12/2016",
         PhotoUrl = "",
         District = "বগুড়া",
         PriceRangeFrom = 100,
         PriceRangeTo = 110
     };
 }
        public void Demonstrate_DbReferenceFetch()
        {
            var supplier = new Supplier { Name = "Acme" };
            supplier.Save();

            var product = new Product {
                Name = "Shovel",
                Price = "17.50",
                Sku = "a3k4j22je9",
                Weight = "11",
                Supplier = new DbReference<Supplier>(supplier.Id)
            };
            product.Save();

            var fetched = Product.GetById(product.Id);

            Assert.AreEqual(supplier.Id, fetched.GetRef(x => x.Supplier).Id);
        }
        public void Demonstrate_ActiveRecordStyleAPI()
        {
            var product = new Product {
                Name = "DVD Player",
                Price = "89.95",
                Sku = "d9ejr3jj3e"
            };

            product.Save();

            var fetched = Product.GetById(product.Id);
            Assert.AreEqual(product.Sku, fetched.Sku);

            product.Delete();

            var reFetched = Product.GetById(product.Id);
            Assert.IsNull(reFetched);
        }
Example #8
0
        public void TestSerialization()
        {
            Product product = new Product();

            product.Name = "Apple";
            product.ExpiryDate = new DateTime(2008, 12, 28);
            product.Price = 3.99M;
            product.Sizes = new string[] { "Small", "Medium", "Large" };

            string output = JsonConvert.SerializeObject(product);
            //{
            //  "Name": "Apple",
            //  "ExpiryDate": "2008-12-28T00:00:00",
            //  "Price": 3.99,
            //  "Sizes": [
            //    "Small",
            //    "Medium",
            //    "Large"
            //  ]
            //}
        }
		public void WhenPutNew_ThenSaves()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", true, new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				var product = new Product { Owner = new User { Id = 1, Name = "kzu" } };

				client.Put("4", product);

				var saved = client.Get<Product>("4");

				Assert.Equal(saved.Id, 4);
				Assert.Equal(saved.Owner.Id, product.Owner.Id);
				Assert.Equal(saved.Owner.Name, product.Owner.Name);
			}
		}
Example #10
0
		public void WhenPutUpdate_ThenSaves()
		{
			using (var ws = new HttpWebService<TestService>("http://localhost:20000", "products", true, new ServiceConfiguration()))
			{
				var client = new HttpEntityClient(ws.BaseUri);
				var product = new Product { Id = 1, Owner = new User { Id = 1, Name = "vga" } };

				client.Put(resourceName, "1", product);

				var saved = client.Get<Product>(resourceName, "1");

				Assert.Equal(saved.Owner.Name, product.Owner.Name);
			}
		}