Beispiel #1
0
        public void TestTwo_SameServer_DifferentPasswords()
        {
            var collection = new DataAccessPointCollection(true);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle &&
                                                      m.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing) == Mock.Of <IDataAccessCredentials>(u =>
                                                                                                                                                             u.Username == "user1" &&
                                                                                                                                                             u.GetDecryptedPassword() == "pwd1")));

            //cannot add because the second one wants integrated security
            var ex = Assert.Throws <InvalidOperationException>(() =>
                                                               collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                                                                         m.Server == "loco" &&
                                                                                                         m.Database == "A" &&
                                                                                                         m.DatabaseType == DatabaseType.Oracle &&
                                                                                                         m.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing) == Mock.Of <IDataAccessCredentials>(u =>
                                                                                                                                                                                                                u.Username == "user1" &&
                                                                                                                                                                                                                u.GetDecryptedPassword() == "pwd2")))
                                                               );

            //should be relevant error and it shouldn't have been added
            StringAssert.Contains("collection could not agree on a single Password to use to access the data under", ex.InnerException.Message);
            Assert.AreEqual(1, collection.Points.Count);
        }
Beispiel #2
0
        public void TestOneServer_CountCorrect(bool singleServer)
        {
            var collection = new DataAccessPointCollection(singleServer);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.DatabaseType == DatabaseType.Oracle));
            Assert.AreEqual(1, collection.Points.Count);
        }
Beispiel #3
0
        /// <inheritdoc/>
        public DiscoveredServer GetDistinctLiveDatabaseServer()
        {
            IDataAccessPoint[] points;

            if (QueryBuilder?.TablesUsedInQuery != null)
            {
                points = QueryBuilder.TablesUsedInQuery.ToArray(); //get it from the request if it has been built
            }
            else
            {
                points = Catalogue.GetTableInfoList(false); //or from the Catalogue directly if the query hasn't been built
            }
            var singleServer = new DataAccessPointCollection(true, DataAccessContext.DataExport);

            singleServer.AddRange(points);

            return(singleServer.GetDistinctServer());
        }
Beispiel #4
0
        public void TestTwo_SameServer_NoCredentials()
        {
            var collection = new DataAccessPointCollection(true);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle));

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "A" &&
                                                      m.DatabaseType == DatabaseType.Oracle));

            Assert.AreEqual(2, collection.Points.Count);

            //they both go to loco server so the single server should specify loco but no clear db
            var db = collection.GetDistinctServer().GetCurrentDatabase();

            Assert.IsNull(db);
        }
Beispiel #5
0
        public void TestTwo_DifferentDatabaseType()
        {
            var collection = new DataAccessPointCollection(true);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle));

            //cannot add because the second one wants integrated security
            var ex = Assert.Throws <InvalidOperationException>(() =>
                                                               collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                                                                         m.Server == "loco" &&
                                                                                                         m.Database == "A" &&
                                                                                                         m.DatabaseType == DatabaseType.MySql))
                                                               );

            //should be relevant error and it shouldn't have been added
            StringAssert.Contains("There was a mismatch on DatabaseType for data access points", ex.InnerException.Message);
            Assert.AreEqual(1, collection.Points.Count);
        }
Beispiel #6
0
        public void TestTwo_SameServer_SameCredentials()
        {
            var collection = new DataAccessPointCollection(true);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle &&
                                                      m.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing) == Mock.Of <IDataAccessCredentials>(u =>
                                                                                                                                                             u.Username == "ff" &&
                                                                                                                                                             u.GetDecryptedPassword() == "pwd")));

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "A" &&
                                                      m.DatabaseType == DatabaseType.Oracle &&
                                                      m.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing) == Mock.Of <IDataAccessCredentials>(u =>
                                                                                                                                                             u.Username == "ff" &&
                                                                                                                                                             u.GetDecryptedPassword() == "pwd")));

            Assert.AreEqual(2, collection.Points.Count);
        }
Beispiel #7
0
        public void TestTwo_SameServer_PersistDatabase()
        {
            var collection = new DataAccessPointCollection(true);

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle &&
                                                      m.GetQuerySyntaxHelper() == new OracleQuerySyntaxHelper()));

            collection.Add(Mock.Of <IDataAccessPoint>(m =>
                                                      m.Server == "loco" &&
                                                      m.Database == "B" &&
                                                      m.DatabaseType == DatabaseType.Oracle &&
                                                      m.GetQuerySyntaxHelper() == new OracleQuerySyntaxHelper()));

            Assert.AreEqual(2, collection.Points.Count);

            //they both go to B so the single server should specify B
            var db = collection.GetDistinctServer().GetCurrentDatabase();

            Assert.AreEqual("B", db.GetRuntimeName());
        }