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 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(); }
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(); }
static void Main(string[] args) { Console.WriteLine("Writing 1000 records sync"); var sw = new Stopwatch(); var products = new BiggyList<Product>(); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU"+ i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.Save(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Resetting..."); products.ClearAndSave(); Console.WriteLine("Writing 1000 records async"); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.SaveAsync(); sw.Stop(); Console.WriteLine("{0}ms",sw.ElapsedMilliseconds); sw.Reset(); //1000 writes? Console.WriteLine("Writing 1000 records with write happening in a loop"); sw.Start(); for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); //bad idea... run it and see why products.Save(); } sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Reading from records"); sw.Start(); var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault(); Console.WriteLine(p2.Sku); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); Console.Read(); }
static void Main(string[] args) { Console.WriteLine("Writing 1000 records sync"); var sw = new Stopwatch(); var products = new BiggyList <Product>(); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.Save(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Resetting..."); products.ClearAndSave(); Console.WriteLine("Writing 1000 records async"); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.SaveAsync(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); //1000 writes? Console.WriteLine("Writing 1000 records with write happening in a loop"); sw.Start(); for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); //bad idea... run it and see why products.Save(); } sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Reading from records"); sw.Start(); var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault(); Console.WriteLine(p2.Sku); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); Console.Read(); }