Пример #1
0
        public void CheckTableScheme_TableSchemeHasAttributeWithUnknownType_ThrowsInvalidAttributeException()
        {
            // Arrange
            string tableName     = "testTable";
            string attributeName = "testAttribute";

            string[] attributeTypes = { null, "testType" };

            // Arrange - create target
            DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings);

            // Act and Assert
            foreach (string attributeType in attributeTypes)
            {
                Models.Attribute attribute = new Models.Attribute {
                    Name = attributeName, Type = attributeType
                };

                TableScheme tableScheme = new TableScheme(tableName, new List <Models.Attribute> {
                    attribute
                });

                InvalidTableAttributesException ex =
                    Assert.Throws <InvalidTableAttributesException>(() => target.CheckTableScheme(tableScheme));

                Assert.NotNull(ex.InnerException);
                Assert.AreSame(ex.InnerException.GetType(), typeof(InvalidAttributeException));
            }
        }
Пример #2
0
        public void CheckTableScheme_TableSchemeHasAttributeWithNotUniqueName_ThrowsInvalidTableAttributesException()
        {
            // Arrange
            string attributeName = "someAttribute";
            string attributeType = this._dbValidationSettings.DataTypes.Keys.First();

            TableScheme tableScheme = new TableScheme("testTable",
                                                      new List <Models.Attribute>
            {
                new Models.Attribute {
                    Name = attributeName, Type = attributeType
                },
                new Models.Attribute {
                    Name = attributeName, Type = attributeType
                }
            });

            // Arrange - create target
            DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings);

            // Act and Assert
            InvalidTableAttributesException ex =
                Assert.Throws <InvalidTableAttributesException>(() => target.CheckTableScheme(tableScheme));

            Assert.NotNull(ex.InnerException);
            Assert.AreSame(ex.InnerException.GetType(), typeof(InvalidAttributeException));
        }