Example #1
0
        public DataTypeInfo Instantiate(RelationalRow row)
        {
            DataTypeInfo dataTypeInfo = null;


            if (row.CharacterMaximumLength > 0)
            {
                dataTypeInfo = new TextInfo();
                ((TextInfo)dataTypeInfo).Length    = row.CharacterMaximumLength;
                ((TextInfo)dataTypeInfo).CharSet   = row.CharacterSetName;
                ((TextInfo)dataTypeInfo).Collation = row.CollationName;
                ((TextInfo)dataTypeInfo).Domain    = row.DomainName;
            }
            else if (row.NumericScale > 0)
            {
                dataTypeInfo = new NumericInfo();
                ((NumericInfo)dataTypeInfo).Scale     = row.NumericScale;
                ((NumericInfo)dataTypeInfo).Precision = row.NumericPrecision;
            }
            else if (row.DateTimePrecision > 0)
            {
                dataTypeInfo = new DateTimeInfo();
                ((DateTimeInfo)dataTypeInfo).Precision = row.DateTimePrecision;
            }
            else
            {
                dataTypeInfo = new DataTypeInfo();
            }

            dataTypeInfo.Name     = row.DataType.ToLower();
            dataTypeInfo.Nullable = row.IsNullable.ToUpper() == "YES".ToUpper();
            return(dataTypeInfo);
        }
        public DataTypeInfo Instantiate(RelationalRow row)
        {
            DataTypeInfo dataTypeInfo = null;

            if (row.CharacterMaximumLength > 0)
            {
                dataTypeInfo = new TextInfo();
                ((TextInfo)dataTypeInfo).Length = row.CharacterMaximumLength;
                ((TextInfo)dataTypeInfo).CharSet = row.CharacterSetName;
                ((TextInfo)dataTypeInfo).Collation = row.CollationName;
                ((TextInfo)dataTypeInfo).Domain = row.DomainName;
            }
            else if (row.NumericScale > 0)
            {
                dataTypeInfo = new NumericInfo();
                ((NumericInfo)dataTypeInfo).Scale = row.NumericScale;
                ((NumericInfo)dataTypeInfo).Precision = row.NumericPrecision;
            }
            else if (row.DateTimePrecision > 0)
            {
                dataTypeInfo = new DateTimeInfo();
                ((DateTimeInfo)dataTypeInfo).Precision = row.DateTimePrecision;
            }
            else
            {
                dataTypeInfo = new DataTypeInfo();
            }

            dataTypeInfo.Name = row.DataType.ToLower();
            dataTypeInfo.Nullable = row.IsNullable.ToUpper() == "YES".ToUpper();
            return dataTypeInfo;
        }
Example #3
0
        public void Matches_Decimal10Coma3_Success()
        {
            var actual = new NumericInfo() { Name = "decimal", Precision=10 , Scale = 3 };

            var commandStub = new Mock<IDataTypeDiscoveryCommand>();
            commandStub.Setup(cmd => cmd.Execute()).Returns(actual);

            var isConstraint = new IsConstraint("decimal(10,3)");

            //Method under test
            Assert.That(commandStub.Object, isConstraint);
        }
Example #4
0
        protected DataTypeInfo Decrypt(string type)
        {
            DataTypeInfo value = null;

            switch (type)
            {
            case "bit":
                value = new DataTypeInfo();
                break;

            case "ntext":
            case "nvarchar":
            case "varchar":
            case "nchar":
            case "text":
            case "char":
                value = new TextInfo();
                break;

            case "smalldatetime":
            case "datetime":
                value = new DateTimeInfo();
                break;

            case "bigint":
            case "money":
            case "smallmoney":
            case "decimal":
            case "float":
            case "int":
            case "real":
            case "smallint":
            case "tinyint":
                value = new NumericInfo();
                break;

            default:
                value = new DataTypeInfo();
                break;
            }

            value.Name = type;
            return(value);
        }
Example #5
0
        public void Matches_Decimal10Coma3WithDecimal10Coma2_Failure()
        {
            var description = new CommandDescription(Target.Columns,
                        new CaptionFilter[]
                            {
                                new CaptionFilter(Target.Perspectives, "perspective-name")
                                , new CaptionFilter(Target.Tables, "table-name")
                                , new CaptionFilter(Target.Columns, "ccc-name")
                        });
            var actual = new NumericInfo() { Name = "decimal", Scale = 10, Precision=3 };

            var commandStub = new Mock<IDataTypeDiscoveryCommand>();
            commandStub.Setup(cmd => cmd.Execute()).Returns(actual);
            commandStub.Setup(cmd => cmd.Description).Returns(description);

            var isConstraint = new IsConstraint("decimal(10,2)");

            //Method under test
            Assert.Throws<AssertionException>(delegate { Assert.That(commandStub.Object, isConstraint); });
        }
        protected DataTypeInfo Decrypt(string type)
        {
            DataTypeInfo value = null;
            switch (type)
            {
                case "bit":
                    value = new DataTypeInfo();
                    break;
                case "ntext":
                case "nvarchar":
                case "varchar":
                case "nchar":
                case "text":
                case "char":
                    value = new TextInfo();
                    break;
                case "smalldatetime":
                case "datetime":
                    value = new DateTimeInfo();
                    break;
                case "bigint":
                case "money":
                case "smallmoney":
                case "decimal":
                case "float":
                case "int":
                case "real":
                case "smallint":
                case "tinyint":
                    value = new NumericInfo();
                    break;
                default:
                    value = new DataTypeInfo();
                    break;
            }

            value.Name = type;
            return value;
        }
Example #7
0
        public void WriteTo_FailingAssertionForNumericType_TextContainsTwoFullTypeNames()
        {
            var description = new CommandDescription(Target.Columns,
                        new CaptionFilter[]
                            {
                                new CaptionFilter(Target.Perspectives, "perspective-name")
                                , new CaptionFilter(Target.Tables, "table-name")
                                , new CaptionFilter(Target.Columns, "ccc-name")
                        });

            var actual = new NumericInfo() { Name = "decimal", Precision=10, Scale = 3 };

            var commandStub = new Mock<IDataTypeDiscoveryCommand>();
            commandStub.Setup(cmd => cmd.Execute()).Returns(actual);
            commandStub.Setup(cmd => cmd.Description).Returns(description);

            var isConstraint = new IsConstraint("decimal(11,2)");

            //Method under test
            string assertionText = null;
            try
            {
                Assert.That(commandStub.Object, isConstraint);
            }
            catch (AssertionException ex)
            {
                assertionText = ex.Message;
            }

            //Test conclusion
            Console.WriteLine(assertionText);
            Assert.That(assertionText, Is.StringContaining("decimal(11,2)").And
                                            .StringContaining("decimal(10,3)")
                                            );
        }
Example #8
0
        public void Matches_Int_Success()
        {
            var actual = new NumericInfo() { Name = "int" };

            var commandStub = new Mock<IDataTypeDiscoveryCommand>();
            commandStub.Setup(cmd => cmd.Execute()).Returns(actual);

            var isConstraint = new IsConstraint("int");

            //Method under test
            Assert.That(commandStub.Object, isConstraint);
        }