public void AverageTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" + "<avg>PRICE</avg>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings { Encoding = Encoding.GetEncoding("UTF-8") }; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); SelectBuilder builder = new SelectBuilder(); ISelect[] fields = builder.Average("PRICE").GetFields(); foreach (var field in fields) { field.WriteXml(ref xml); } xml.Flush(); stream.Position = 0; StreamReader reader = new StreamReader(stream); Assert.Equal(expected, reader.ReadToEnd()); }