public void ProductDictionarySerializationXMLTest() { Dictionary <int, Product> products = new Dictionary <int, Product> { { 0, new Product { Name = "Yamaha 2.0", Price = 3200.99 } }, { 1, new Product { Name = "Yamaha 2", Price = 400.99 } }, { 2, new Product { Name = "Ibanez 2111", Price = 402130.99 } }, { 3, new Product { Name = "Cort 242", Price = 4111100.99 } }, { 4, new Product { Name = "Yamaha -4", Price = 4500.99 } }, }; XMLConverter xmlc = new XMLConverter(); xmlc.writeProductsDictionary(products, "products.txt"); Dictionary <int, Product> deProducts = xmlc.readProductsDictionary("products.txt"); for (int i = 0; i < products.Count; i++) { Assert.AreEqual(products[i].ToString(), deProducts[i].ToString()); } }
public void ProductDictionarySerializationCountXMLTest() { Dictionary <int, Product> products = new Dictionary <int, Product> { { 1, new Product { Name = "Yamaha 2", Price = 400.99 } }, { 2, new Product { Name = "Ibanez 2111", Price = 402130.99 } }, { 3, new Product { Name = "Cort 242", Price = 4111100.99 } }, { 4, new Product { Name = "Yamaha -4", Price = 4500.99 } }, }; XMLConverter xmlc = new XMLConverter(); xmlc.writeProductsDictionary(products, "products.txt"); Dictionary <int, Product> deProducts = xmlc.readProductsDictionary("products.txt"); Assert.AreEqual(products.Count, deProducts.Count); }