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)); } }
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)); }
public void CheckTableScheme_TableSchemeIsNull_ThrowsArgumentNullException() { // Arrange - create target DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings); // Act and Assert Assert.Throws <ArgumentNullException>(() => target.CheckTableScheme(null)); }
public void CheckTableScheme_TableSchemeHasNoAttributes_ThrowsInvalidTableAttributesException() { // Arrange TableScheme tableScheme = new TableScheme("testTable", new List <Models.Attribute>()); // Arrange - create target DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings); // Act and Assert Assert.Throws <InvalidTableAttributesException>(() => target.CheckTableScheme(tableScheme)); }
public void CheckTableScheme_TableSchemeIsValid_DoesNotThrowAnyException() { // Arrange TableScheme tableScheme = new TableScheme("testTable", new List <Models.Attribute> { new Models.Attribute { Name = "testAttribute", Type = this._dbValidationSettings.DataTypes.Keys.First() } }); // Arrange - create target DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings); // Act and Assert Assert.DoesNotThrow(() => target.CheckTableScheme(tableScheme)); }
public void CheckTableScheme_TableSchemeHasInvalidName_ThrowsInvalidTableNameException() { // Arrange string[] tableNames = { "", " ", new string(Path.GetInvalidFileNameChars()) }; Models.Attribute[] attributes = { new Models.Attribute { Name = "testAttribute", Type = this._dbValidationSettings.DataTypes.Keys.First() } }; // Arrange - create target DatabaseValidation target = new DatabaseValidation(this._dbValidationSettings); // Act and Assert foreach (string tableName in tableNames) { TableScheme tableScheme = new TableScheme(tableName, attributes); Assert.Throws <InvalidTableNameException>(() => target.CheckTableScheme(tableScheme)); } }