コード例 #1
0
        public void ColumnFormatter_Creates_Single_Nullable_String_Column_Correctly()
        {
            // Arrange
            var summary = new ClassSummary
            {
                Columns = new TableColumnProperties
                {
                    NormalColumns = new List<NormalColumn> { new NormalColumn("TmStamp", "TimeStamp", false) }
                }
            };

            var formatter = new StandardSIFormatter(summary);

            // Act
            var columnDefinition = formatter.Columns();

            // Assert
            Assert.AreEqual(@"    TmStamp TIMESTAMP NULL

", columnDefinition);
        }
コード例 #2
0
        public void ColumnFormatter_Creates_Single_String_Column_Correctly()
        {
            // Arrange
            var summary = new ClassSummary
            {
                Columns = new TableColumnProperties
                {
                    NormalColumns = new List<NormalColumn> { new NormalColumn("Id", "String", true) { Length = 10 } }
                }
            };

            var formatter = new StandardSIFormatter(summary);

            // Act
            var columnDefinition = formatter.Columns();

            // Assert
            Assert.AreEqual(@"    Id CHAR(10)

", columnDefinition);
        }
コード例 #3
0
 public StandardSIFormatter(ClassSummary summary)
 {
     _summary = summary;
 }
コード例 #4
0
ファイル: Parser.cs プロジェクト: WilliamBZA/SI.Generator
 private FormattedResults FormatResults(ClassSummary summary)
 {
     var formatter = new StandardSIFormatter(summary);
     return formatter.FormatIntoObject();
 }
コード例 #5
0
        public void ColumnFormatter_Formats_Complex_Object_Correctly()
        {
            // Arrange
            var summary = new ClassSummary
            {
                Columns = new TableColumnProperties
                {
                    NormalColumns = new List<NormalColumn> {
                        new NormalColumn("RecordLegId", "Int32", true),
                        new NormalColumn("ContactName", "String", false) { Length = 10 },
                        new NormalColumn("ContactSurname", "String", false) { Length = 10 },
                        new NormalColumn("EmailAddress", "String", false) { Length = 120 },
                        new NormalColumn("FaxNumber", "String", false) { Length = 15 },
                        new NormalColumn("TelephoneNumber", "String", false) { Length = 15 },
                        new NormalColumn("PhysicalAddressId", "Int32", false),
                        new NormalColumn("PostalAddressId", "Int32", false)
                    }
                }
            };

            var formatter = new StandardSIFormatter(summary);

            // Act
            var columnDefinition = formatter.Columns();

            // Assert
            Assert.AreEqual(@"    RecordLegId INT
    ContactName CHAR(10) NULL
    ContactSurname CHAR(10) NULL
    EmailAddress CHAR(120) NULL
    FaxNumber CHAR(15) NULL
    TelephoneNumber CHAR(15) NULL
    PhysicalAddressId INT NULL
    PostalAddressId INT NULL

", columnDefinition);
        }
コード例 #6
0
        public void ColumnFormatter_Creates_Multiple_Int_Columns_With_One_Nullable_Correctly()
        {
            // Arrange
            var summary = new ClassSummary
            {
                Columns = new TableColumnProperties
                {
                    NormalColumns = new List<NormalColumn> {
                        new NormalColumn("Id", "Int32", true),
                        new NormalColumn("Age", "Int32", false),
                    }
                }
            };

            var formatter = new StandardSIFormatter(summary);

            // Act
            var columnDefinition = formatter.Columns();

            // Assert
            Assert.AreEqual(@"    Id INT
    Age INT NULL

", columnDefinition);
        }
コード例 #7
0
        public void ColumnFormatter_Creates_Single_Nullable_Decimal_With_Custom_Length_And_Precision_Column_Correctly()
        {
            // Arrange
            var summary = new ClassSummary
            {
                Columns = new TableColumnProperties
                {
                    NormalColumns = new List<NormalColumn> { new NormalColumn("InterestRate", "Decimal", false) { Length = 99, Precision = 6 } }
                }
            };

            var formatter = new StandardSIFormatter(summary);

            // Act
            var columnDefinition = formatter.Columns();

            // Assert
            Assert.AreEqual(@"    InterestRate FLOAT(99, 6) NULL

", columnDefinition);
        }