public void ReturnsCorrectValueForTestObjectContext() { string expectedValue = string.Format("metadata=res://*/TestObjectContext.csdl|res://*/TestObjectContext.ssdl|res://*/TestObjectContext.msl;provider=System.Data.SqlClient;provider connection string=\"{0}\"", TestConnectionStrings.ObjectContextDefault); var connectionString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextDefault); Assert.AreEqual(expectedValue, connectionString); }
public void ThrowsArgumentExceptionForNullOrWhitespaceConnectionString() { var connectionString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextDefault); var objectContext = new TestObjectContextContainer(connectionString); ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => ConnectionStringHelper.SetConnectionString(objectContext, null)); ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => ConnectionStringHelper.SetConnectionString(objectContext, string.Empty)); }
public void ReturnsNamedConnectionString() { var context = new TestObjectContextContainer(); string expectedString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextDefault); var connectionString = context.GetConnectionString(); Assert.IsTrue(string.Equals(expectedString, connectionString, StringComparison.OrdinalIgnoreCase)); }
public void ReturnsNamedConnectionString() { var context = new TestObjectContextContainer(); string expectedString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextDefault); var connectionString = context.GetConnectionString(); Assert.AreEqual(expectedString, connectionString, true); }
public void SetsConnectionString() { var connectionString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextDefault); var objectContext = new TestObjectContextContainer(connectionString); objectContext.SetConnectionString(TestConnectionStrings.ObjectContextModified); var expectedConnectionString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextModified); Assert.AreEqual(expectedConnectionString, objectContext.Connection.ConnectionString); }
public void ReturnsRealConnectionString() { using (var context = new TestObjectContextContainer()) { var expectedString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextModified); context.SetConnectionString(TestConnectionStrings.ObjectContextModified); var connectionString = context.GetConnectionString(); Assert.IsTrue(string.Equals(expectedString, connectionString, StringComparison.OrdinalIgnoreCase)); } }
public void ThrowsArgumentExceptionForNullAndEmptyConnectionString() { ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), null)); ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), string.Empty)); }
public void ThrowsArgumentNullExceptionForNullContextType() { ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => EfConnectionStringHelper.GetEntityFrameworkConnectionString(null, TestConnectionStrings.ObjectContextDefault)); }