public void IdentifierConstructorTest() { string serverIdentifier = "(local)"; string databaseIdentifier = "master"; string schemaIdentifier = "dbo"; string baseIdentifier = "tables"; Identifier.IdentifierEnum identifierType = Identifier.IdentifierEnum.Table; Identifier target = new Identifier(serverIdentifier, databaseIdentifier, schemaIdentifier, baseIdentifier, identifierType); Assert.AreEqual("[(local)].[master].[dbo].[tables]", target.ToString()); Assert.AreEqual(Identifier.IdentifierEnum.Table, target.IdentifierType); }
public void IdentifierConstructorTest2() { bool caught = false; string serverIdentifier = "(local)"; string databaseIdentifier = "master"; string schemaIdentifier = "dbo"; string baseIdentifier = string.Empty; Identifier.IdentifierEnum identifierType = Identifier.IdentifierEnum.Table; try { Identifier target = new Identifier(serverIdentifier, databaseIdentifier, schemaIdentifier, baseIdentifier, identifierType); } catch (Exception ex) { Assert.AreEqual("baseIdentifier can NOT be an empty string", ex.Message); caught = true; } Assert.AreEqual(true, caught); }
public void ToStringTest1() { Identifier target = new Identifier(); string expected = "[]"; string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); string serverIdentifier = "(local)"; string databaseIdentifier = "master"; string schemaIdentifier = "dbo"; string baseIdentifier = "tables"; Identifier.IdentifierEnum identifierType = Identifier.IdentifierEnum.Table; target = new Identifier(serverIdentifier, databaseIdentifier, schemaIdentifier, baseIdentifier, identifierType); expected = "[(local)].[master].[dbo].[tables]"; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.AreEqual(4, target.Qualifiers); target = new Identifier(serverIdentifier, databaseIdentifier, string.Empty, baseIdentifier, identifierType); expected = "[(local)].[master]..[tables]"; actual = target.ToString(); Assert.AreEqual(expected, actual); target = new Identifier(serverIdentifier, databaseIdentifier, string.Empty, baseIdentifier, identifierType); expected = "[(local)].[master]..[tables]"; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.AreEqual(3, target.Qualifiers); target = new Identifier(serverIdentifier, string.Empty, string.Empty, baseIdentifier, identifierType); expected = "[(local)]...[tables]"; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.AreEqual(2, target.Qualifiers); target = new Identifier(string.Empty, string.Empty, string.Empty, baseIdentifier, identifierType); expected = "[tables]"; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.AreEqual(1, target.Qualifiers); }
public void ToStringTest() { Identifier target = new Identifier(); bool forceSchemaQualified = false; string expected = "[]"; string actual; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); expected = "[dbo].[]"; forceSchemaQualified = true; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); string serverIdentifier = "(local)"; string databaseIdentifier = "master"; string schemaIdentifier = "dbo"; string baseIdentifier = "tables"; Identifier.IdentifierEnum identifierType = Identifier.IdentifierEnum.Table; target = new Identifier(serverIdentifier, databaseIdentifier, schemaIdentifier, baseIdentifier, identifierType); expected = "[(local)].[master].[dbo].[tables]"; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); forceSchemaQualified = false; target = new Identifier(serverIdentifier, databaseIdentifier, string.Empty, baseIdentifier, identifierType); expected = "[(local)].[master]..[tables]"; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); forceSchemaQualified = true; target = new Identifier(serverIdentifier, databaseIdentifier, string.Empty, baseIdentifier, identifierType); expected = "[(local)].[master].[dbo].[tables]"; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); target = new Identifier(serverIdentifier, string.Empty, string.Empty, baseIdentifier, identifierType); expected = "[(local)]..[dbo].[tables]"; actual = target.ToString(forceSchemaQualified); Assert.AreEqual(expected, actual); }