public void WontDuplicate() { _products.Purge(); _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.Purge(); 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.Purge(); 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 WhatWhat() { // var sw = new Stopwatch(); // sw.Start(); // var products = new MassiveList<NWProduct>(connectionStringName: "northwind", tableName: "products", primaryKeyName: "productid"); // sw.Stop(); // Console.WriteLine("Read " + products.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // foreach (var p in products) { // Console.WriteLine(p.Sku); // } // sw.Reset(); // sw.Start(); // var readOne = products.FirstOrDefault(x => x.ProductName == "Product24"); // Console.WriteLine(readOne.ProductName); // sw.Stop(); // Console.WriteLine("Read single in " + sw.ElapsedMilliseconds + "ms"); // sw.Reset(); // sw.Start(); // var details = new MassiveList<OrderDetail>(connectionStringName: "northwind", tableName: "orderdetails", primaryKeyName: "orderdetailid"); // sw.Stop(); // Console.WriteLine("Read " + details.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // Console.Read(); //} static void RunBenchmarks() { 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.Purge(); 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 WhatWhat() { // var sw = new Stopwatch(); // sw.Start(); // var products = new MassiveList<NWProduct>(connectionStringName: "northwind", tableName: "products", primaryKeyName: "productid"); // sw.Stop(); // Console.WriteLine("Read " + products.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // foreach (var p in products) { // Console.WriteLine(p.Sku); // } // sw.Reset(); // sw.Start(); // var readOne = products.FirstOrDefault(x => x.ProductName == "Product24"); // Console.WriteLine(readOne.ProductName); // sw.Stop(); // Console.WriteLine("Read single in " + sw.ElapsedMilliseconds + "ms"); // sw.Reset(); // sw.Start(); // var details = new MassiveList<OrderDetail>(connectionStringName: "northwind", tableName: "orderdetails", primaryKeyName: "orderdetailid"); // sw.Stop(); // Console.WriteLine("Read " + details.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // Console.Read(); //} static void RunBenchmarks() { 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.Purge(); 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(); }