Beispiel #1
0
        public void AssertEqual(ProductData other)
        {
            Assert.AreNotEqual(other, null);

            Assert.AreEqual(other.Name, Name, "name");
            Assert.AreEqual(other.StartDate, StartDate, "startDate");
            Assert.AreEqual(other.LaunchTime, LaunchTime, "launchTime");
            Assert.AreEqual(other.Weight, Weight, "weight");
            Assert.AreEqual(other.NbrAvailable, NbrAvailable, "nbrAvailable");
            Assert.AreEqual(BigEndianBitConverter.NormalizeString(other.ShopsAvailable), BigEndianBitConverter.NormalizeString(ShopsAvailable), "shopsAvailable");
            Assert.AreEqual(other.HexProductCode, HexProductCode, "hexProductCode");
            Assert.AreEqual(other.Onsale, Onsale, "onsale");
            Assert.AreEqual(other.RetailPrice, RetailPrice, "retailPrice");
            Assert.AreEqual(BigEndianBitConverter.NormalizeString(other.Description), BigEndianBitConverter.NormalizeString(Description), "description");
        }
Beispiel #2
0
        public void GoodFileTabDelimitedNoNamesInFirstLineNLnl()
        {
            // Arrange

            CsvFileDescription fileDescription_nonamesNl = new CsvFileDescription
            {
                SeparatorChar             = '\t', // tab character
                FirstLineHasColumnNames   = false,
                EnforceCsvColumnAttribute = true,
                FileCultureName           = "nl-NL" // default is the current culture
            };

            const string testInput = "moonbuggy\t       23/5/08\t   5-Mei-2009 16:11 pm\t   34.184\t  \"Paris, New York\"\t 1F\t    €540,12\t        true\t  newly launched product\n\"mouse trap\"\t        2/1/1985\t  \"7 Augustus 1988\t 0:00\"\t45E-5\t \"This field has\na newline\"\t 100\t \"€78.300\"\t     FALSE\t \"This field has quotes(\"\"), and\r\ntwo newlines\r\nand a quoted \"\"string\"\"\"\r\ndog house\t29 Feb 2004\t \t    \"45.230.990\"\t\"\"\t                  FF10\t \"12.008\"\t        True";
            var          expected  = new[] {
                new ProductData {
                    Name           = "moonbuggy", Weight = 34184, StartDate = new DateTime(2008, 5, 23),
                    LaunchTime     = new DateTime(2009, 5, 5, 16, 11, 0),
                    NbrAvailable   = 0, Onsale = true, ShopsAvailable = "Paris, New York",
                    HexProductCode = 31, RetailPrice = 540.12M,
                    Description    = "newly launched product"
                },
                new ProductData {
                    Name         = "mouse trap", Weight = 45E-5, StartDate = new DateTime(1985, 1, 2),
                    LaunchTime   = new DateTime(1988, 8, 7, 0, 0, 0),
                    NbrAvailable = 0, Onsale = false, ShopsAvailable = @"This field has
a newline", HexProductCode = 256, RetailPrice = 78300M,
                    Description  = @"This field has quotes(""), and
two newlines
and a quoted ""string"""
                },
                new ProductData {
                    Name           = "dog house", Weight = 45230990, StartDate = new DateTime(2004, 2, 29),
                    LaunchTime     = default(DateTime),
                    NbrAvailable   = 0, Onsale = true, ShopsAvailable = "",
                    HexProductCode = 65296, RetailPrice = 12008M,
                    Description    = null
                }
            };

            // Act and Assert
            AssertRead(BigEndianBitConverter.NormalizeString(testInput), fileDescription_nonamesNl, expected);
        }
Beispiel #3
0
        public void AssertWrite <T>(IEnumerable <T> values, CsvFileDescription fileDescription, string expected) where T : class
        {
            string actual = TestWrite <T>(values, fileDescription);

            Assert.AreEqual(BigEndianBitConverter.NormalizeString(actual), BigEndianBitConverter.NormalizeString(expected));
        }