public void Extensions_GetPhysicalFileName_Returns_Null_If_Not_Found() { // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder(); // Act string result = value.GetPhysicalFileName(); // Assert Assert.IsNull(result, "GetPhysicalFileName() returned incorrect value."); }
public void Extensions_GetPhysicalFileName_Returns_Correct_FileName() { // Arrange string connectionString = Convert.ToString(this.TestContext.DataRow["connectionString"], CultureInfo.InvariantCulture); string expected = Convert.ToString(this.TestContext.DataRow["expected"], CultureInfo.InvariantCulture); // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder() { ConnectionString = connectionString, }; // Act string actual = value.GetPhysicalFileName(); // Assert Assert.AreEqual(expected, actual, "GetPhysicalFileName() returned incorrect value."); }
public void Extensions_SetPhysicalFileName_Sets_Correct_Value_If_Relative_Path_Used() { // Arrange string connectionString = @"data source=.;attachdbfilename=MyDatabase.mdf;integrated security=True;MultipleActiveResultSets=True"; string fileName = @".\MyDatabase.mdf"; string expected = Path.GetFullPath(fileName); // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder() { ConnectionString = connectionString, }; // Act value.SetPhysicalFileName(fileName); // Assert string result = value.GetPhysicalFileName(); Assert.AreEqual(expected, result, "SetPhysicalFileName() did not set the correct value."); }
public void Extensions_SetPhysicalFileName_Sets_Correct_Value_If_Null_Specified() { // Arrange string connectionString = @"data source=.;attachdbfilename=MyDatabase.mdf;integrated security=True;MultipleActiveResultSets=True"; string fileName = null; // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder() { ConnectionString = connectionString, }; // Act value.SetPhysicalFileName(fileName); // Assert string result = value.GetPhysicalFileName(); Assert.IsNull(result, "SetPhysicalFileName() did not set the correct value."); }
public void Extensions_SetPhysicalFileName_Sets_Correct_Value_If_Data_Directory_Used_And_Set() { // Arrange var appDomainData = new Dictionary<string, object>() { { "DataDirectory", @"C:\MyDatabases" }, }; Helpers.InvokeInNewAppDomain( () => { string connectionString = @"data source=.;attachdbfilename=MyDatabase.mdf;integrated security=True;MultipleActiveResultSets=True"; string fileName = @"|DataDirectory|\MyDatabase.mdf"; string expected = @"C:\MyDatabases\MyDatabase.mdf"; // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder() { ConnectionString = connectionString, }; // Act value.SetPhysicalFileName(fileName); // Assert string result = value.GetPhysicalFileName(); Assert.AreEqual(expected, result, "SetPhysicalFileName() did not set the correct value."); }, appDomainData: appDomainData); }
public void Extensions_SetPhysicalFileName_Returns_Correct_File_Name() { // Arrange string connectionString = Convert.ToString(this.TestContext.DataRow["connectionString"], CultureInfo.InvariantCulture); string fileName = Convert.ToString(this.TestContext.DataRow["physicalFileName"], CultureInfo.InvariantCulture); // Arrange DbConnectionStringBuilder value = new DbConnectionStringBuilder() { ConnectionString = connectionString, }; // Act value.SetPhysicalFileName(fileName); // Assert string result = value.GetPhysicalFileName(); Assert.AreEqual(fileName, result, "SetPhysicalFileName() did not set the correct value."); }