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));
            }
Beispiel #2
0
            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 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 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 ReturnsRealConnectionString()
            {
                var context = new TestObjectContextContainer();

                string expectedString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextModified);

                context.SetConnectionString(TestConnectionStrings.ObjectContextModified);
                var connectionString = context.GetConnectionString();

                Assert.AreEqual(expectedString, connectionString, true);
            }
            public void ReturnsRealConnectionString()
            {
                var context = new TestObjectContextContainer();

                string expectedString = EfConnectionStringHelper.GetEntityFrameworkConnectionString(typeof(TestObjectContextContainer), TestConnectionStrings.ObjectContextModified);

                context.SetConnectionString(TestConnectionStrings.ObjectContextModified);
                var connectionString = context.GetConnectionString();

                Assert.IsTrue(string.Equals(expectedString, connectionString, StringComparison.OrdinalIgnoreCase));
            }