public void ProductCollection_AddProductsPPAPTest() { ProductCollection products = new ProductCollection(); products.AddNew("Pen"); products.AddNew("Pineapple"); products.AddNew("Apple"); products.AddNew("Pen"); Assert.IsTrue(products.Count == 4); System.Collections.Generic.List <Product> prods = new System.Collections.Generic.List <Product>(); prods.GroupBy(x => x.Name); var results = products.GroupBy(x => x.Name) .Select(x => new { Name = x.Key, Count = x.Count() }); XmlSource.Save(products, "OrderPPAP.xml"); /* Debugger results: * Apple: 3 * Banana: 1 */ //TODO: figure out the syntax to access the count groupings. // debugger shows it properly but adding to the watch window results in an error. }
public void Catalog_InitializeTest() { Catalog c = new Catalog(); string outputFile = "catalog.xml"; c.AddNew("Apple", 0.75M, DateTime.MinValue, new DateTime(2001, 12, 31, 23, 59, 59)); c.AddNew("Apple", 0.75M, new DateTime(2002, 01, 01), null); c.AddNew("Banana", 1.0M, DateTime.MinValue, null); c.AddNew("Orange Juice", 1.1M, DateTime.MinValue, new DateTime(1983, 06, 09, 23, 59, 59)); c.AddNew("Orange Juice", 2.0M, new DateTime(1983, 06, 10), null); c.AddNew("Pineapple", 5.0M, DateTime.MinValue, null); c.AddNew("Pen", 0.99M, DateTime.MinValue, null); XmlSource.Save(c, outputFile); Catalog c2 = XmlSource.Load(typeof(Catalog), outputFile) as Catalog; Assert.IsTrue(c2 != null, "Catalog was not rehydrated successfully"); Assert.IsTrue(c2.Count == c.Count, "Catalog items serialized and rehydrated are not the same count"); Assert.IsTrue(c2.Count > 0, "No objects were rehydrated"); // if (System.IO.File.Exists(outputFile)) // System.IO.File.Delete(outputFile); }
public void XmlDataSource_SerializeCollectionTest1() { string outputFile = @".\products.xml"; IProductCollection products = new kiosk.Model.ProductCollection(); products.AddNew("Apple"); products.AddNew("Banana"); products.AddNew("Apple"); products.AddNew("Apple"); XmlSource.Save(products, outputFile); Assert.IsTrue(System.IO.File.Exists(outputFile)); //Cleanup System.IO.File.Delete(outputFile); }
public override void Processing(string outputFile) { XmlNodeList tableList = this.GetTableList(@"//w:tbl"); //循环表格节点 for (int i = 0; i < tableList.Count; i++) { XmlNodeList rowList = this.GetRowList(tableList[i], @"w:tr"); DoubleLinkedList <XmlNode>[] cellMatrix = new DoubleLinkedList <XmlNode> [rowList.Count]; for (int j = 0; j < cellMatrix.Length; j++) { cellMatrix[j] = new DoubleLinkedList <XmlNode>(); } //处理每一个行 this.RowProcessing(tableList[i], cellMatrix); } XmlSource.Save(outputFile); }
/// <summary> /// 处理一个单元格 /// </summary> public override void Processing(string fileName) { XmlNodeList tableList = this.GetTableList(@"//字:文字表_416C"); //循环表格节点 for (int i = 0; i < tableList.Count; i++) { XmlNodeList rowList = this.GetRowList(tableList[i], @"字:行_41CD"); DoubleLinkedList <XmlNode>[] cellMatrix = new DoubleLinkedList <XmlNode> [rowList.Count]; for (int j = 0; j < cellMatrix.Length; j++) { cellMatrix[j] = new DoubleLinkedList <XmlNode>(); } //处理每一个行 this.RowProcessing(tableList[i], cellMatrix); //TestMethod(i, cellMatrix); } XmlSource.Save(fileName); }
public void XmlDataSource_SerializeCollectionCompareTest() { string outputFile = @".\products.xml"; IProductCollection products = new ProductCollection(); products.AddNew("Apple"); products.AddNew("Banana"); products.AddNew("Apple"); products.AddNew("Apple"); XmlSource.Save(products, outputFile); IProductCollection products2 = XmlSource.Load(typeof(ProductCollection), outputFile) as IProductCollection; Assert.IsNotNull(products2, "ProductCollection could not be rehydrated"); Assert.AreEqual(products.Count, products2.Count, "ProductCollection was not rehydrated with an incorrect count"); //Cleanup System.IO.File.Delete(outputFile); }