public void TestSerializeShouldSerializeColumn()
        {
            var result = _serializer.Serialize(_column);

            AssertValue(result, "id", _column.Id.ToString());
            AssertValue(result, "index", _column.Index.ToString());
            AssertValue(result, "name", _column.Name);
            AssertValue(result, "data-type", "Boolean");
            AssertValue(result, "semantic-type", _column.SemanticType.ToString());
        }
예제 #2
0
        public override void Serialize(TextWriter writer, IEnumerable <World> worlds, SectorSerializeOptions options)
        {
            List <string> cols = new List <string> {
                "Hex",
                "Name",
                "UWP",
                "Remarks",
                "{Ix}",
                "(Ex)",
                "[Cx]",
                "N",
                "B",
                "Z",
                "PBG",
                "W",
                "A",
                "Stellar"
            };

            if (options.includeRoutes)
            {
                cols.Add("Routes");
            }

            ColumnSerializer formatter = new ColumnSerializer(cols);

            formatter.SetMinimumWidth("Name", 20);
            formatter.SetMinimumWidth("Remarks", 20);

            foreach (World world in worlds.OrderBy(world => world.SS))
            {
                List <string> row = new List <string> {
                    options.sscoords?world.SubsectorHex : world.Hex,
                           world.Name,
                           world.UWP,
                           world.Remarks,
                           world.Importance ?? "",
                           world.Economic ?? "",
                           world.Cultural ?? "",
                    DashIfEmpty(world.Nobility ?? ""),
                    DashIfEmpty(world.Bases),
                    DashIfEmpty(world.Zone),
                    world.PBG,
                    world.Worlds > 0 ? world.Worlds.ToString() : "",
                    world.Allegiance,
                    world.Stellar
                };
                if (options.includeRoutes)
                {
                    row.Add(world.Routes ?? "");
                }
                formatter.AddRow(row);
            }
            formatter.Serialize(writer, options.includeHeader);
        }
        public void Serialize_AddsTypeAttribute()
        {
            var propertyDefinition = GetPropertyDefinition((ClassWithAllDataTypes _) => _.Int32Property);
            var classDefinition    = propertyDefinition.ClassDefinition;

            var columnSerializer = new ColumnSerializer();
            var actual           = columnSerializer.Serialize(propertyDefinition, GetRdbmsPersistenceModelProvider(classDefinition)).Single();

            Assert.That(actual.Attributes().Select(a => a.Name.LocalName), Contains.Item("dbType"));
            Assert.That(actual.Attribute("dbType").Value, Is.EqualTo("Int32"));
        }
        public void Serialize_CreatesColumnElement()
        {
            var propertyDefinition = GetPropertyDefinition((ClassWithAllDataTypes _) => _.Int32Property);
            var classDefinition    = propertyDefinition.ClassDefinition;

            var columnSerializer = new ColumnSerializer();
            var actual           = columnSerializer.Serialize(propertyDefinition, GetRdbmsPersistenceModelProvider(classDefinition)).ToArray();

            Assert.That(actual.Length, Is.EqualTo(1));
            Assert.That(actual[0].Name.LocalName, Is.EqualTo("column"));
        }
        public void Serialize_RelationProperty()
        {
            var propertyDefinition = GetPropertyDefinition((Ceo _) => _.Company);
            var classDefinition    = propertyDefinition.ClassDefinition;

            var columnSerializer = new ColumnSerializer();
            var actual           = columnSerializer.Serialize(propertyDefinition, GetRdbmsPersistenceModelProvider(classDefinition)).ToArray();

            Assert.That(actual.Length, Is.EqualTo(2));
            Assert.That(actual[0].Attribute("name").Value, Is.EqualTo("CompanyID"));
            Assert.That(actual[0].Attribute("dbType").Value, Is.EqualTo("Guid"));
            Assert.That(actual[1].Attribute("name").Value, Is.EqualTo("CompanyIDClassID"));
            Assert.That(actual[1].Attribute("dbType").Value, Is.EqualTo("String"));
        }
예제 #6
0
        public void ColumnFormatterTest()
        {
            ColumnSerializer formatter = new ColumnSerializer(new string[] { "1", "2", "3", "4" });

            formatter.AddRow(new string[] { "a", "bb", "ccc", "dddd" });
            formatter.AddRow(new string[] { " A ", "  BB  ", "   CCC   ", "    DDDD    " });
            formatter.AddRow(new string[] { "w", "x", "y", "z" });
            StringWriter writer = new StringWriter();

            formatter.Serialize(writer);
            Assert.AreEqual(
                "1 2  3   4   \r\n" +
                "- -- --- ----\r\n" +
                "a bb ccc dddd\r\n" +
                "A BB CCC DDDD\r\n" +
                "w x  y   z   \r\n",
                writer.ToString());
        }