Example #1
0
        [TestMethod] public void WhitespaceIsStripped()
        {
            // Arrange
            var rawSql = "   Name\t\n\r\n";

            // Act
            var sql      = new SqlSnippet(rawSql);
            var trimmed  = rawSql.Trim();
            var asString = sql.ToString();

            // Assert
            asString.Should().Be(trimmed);
        }
Example #2
0
        static TableTests()
        {
            snippet_ = new SqlSnippet("SQL");

            var mockField0 = new Mock <IField>();

            mockField0.Setup(field => field.Name).Returns(new FieldName("A"));
            mockField0.Setup(field => field.Nullability).Returns(IsNullable.No);
            mockField0.Setup(field => field.DataType).Returns(DBType.Int32);
            mockField0.Setup(field => field.GenerateDeclaration(It.IsAny <IFieldDeclBuilder>())).Returns(snippet_);
            var mockField1 = new Mock <IField>();

            mockField1.Setup(field => field.Name).Returns(new FieldName("B"));
            mockField1.Setup(field => field.Nullability).Returns(IsNullable.No);
            mockField1.Setup(field => field.DataType).Returns(DBType.Guid);
            mockField1.Setup(field => field.GenerateDeclaration(It.IsAny <IFieldDeclBuilder>())).Returns(snippet_);
            var mockField2 = new Mock <IField>();

            mockField2.Setup(field => field.Name).Returns(new FieldName("C"));
            mockField2.Setup(field => field.Nullability).Returns(IsNullable.No);
            mockField2.Setup(field => field.DataType).Returns(DBType.Enumeration);
            mockField2.Setup(field => field.GenerateDeclaration(It.IsAny <IFieldDeclBuilder>())).Returns(snippet_);

            var pkey  = new PrimaryKey(new IField[] { mockField0.Object });
            var ckey  = new CandidateKey(new IField[] { mockField1.Object });
            var check = new CheckConstraint(new Mock <Clause>().Object);

            var mockReferenceTable = new Mock <ITable>();

            mockReferenceTable.Setup(table => table.PrimaryKey).Returns(pkey);
            var fkey = new ForeignKey(mockReferenceTable.Object, pkey.Fields, OnDelete.SetNull, OnUpdate.NoAction);

            table_ = new Table(new TableName("TABLE"),
                               new IField[] { mockField1.Object, mockField2.Object, mockField0.Object }, pkey,
                               new CandidateKey[] { ckey }, new ForeignKey[] { fkey }, new CheckConstraint[] { check });
        }