コード例 #1
0
        public void SerrializeToCsvTest()
        {
            var flights = GetFlights();

            var text     = BASerrializor.SerrializeToCsv(flights, ";");
            var title    = string.Empty;
            var firstRow = string.Empty;

            using (StringReader stringReader = new StringReader(text))
            {
                title    = stringReader.ReadLine();
                firstRow = stringReader.ReadLine();
            }

            Assert.AreEqual("CsvCity;CsvNumber;CsvStatus", title);
            Assert.AreEqual("London;1;Unknown", firstRow, "my message");
        }
コード例 #2
0
        public void SerrializeToXmlTest()
        {
            //arrange
            var flights = GetFlights();

            //act
            var xElement = BASerrializor.SerrializeToXml(flights);
            var elements = xElement.Descendants("Flight");

            var        counter = 0;
            XAttribute attr    = null;

            foreach (var item in elements)
            {
                counter++;
                attr = item.Attribute("Status");
            }

            //assert
            Assert.AreEqual(4, counter);
            Assert.IsTrue(attr.Value == "Arrived1");
        }