Esempio n. 1
0
        public void BookBalanceSQLite()
        {
            var profile  = new Profile.Profile();
            var database = new Fake.Database(profile);

            database.Connect();

            var   bookName   = "Sales";
            float bookAmount = 100.00F;

            database.Add(record1);
            database.Add(record2);

            System.Collections.Generic.List <Balance> entries = Function.SQLiteBookBalance(database, bookName, bookAmount);
            CheckTransaction(database);

            Assert.Greater(entries.Count, 1);
            Assert.IsNotNull(entries[0].Entry);
            Assert.Greater(entries[0].Entry, 0);
            Assert.AreEqual(record1[2], entries[0].Account);
            Assert.AreEqual(record2[2], entries[1].Account);

            Assert.AreEqual(1, database.Connection.OpenCount);
            Assert.Less(database.Connection.CloseCount, 2);
        }
Esempio n. 2
0
        public void NoResultFromDatabase()
        {
            var profile  = new Profile.Profile();
            var database = new Fake.Database(profile);

            database.Connect();

            Assert.AreEqual("0.0.0-Nil", database.SchemaVersion().ToString());
        }
Esempio n. 3
0
 public void Setup()
 {
     log     = new Core.Fake.Log();
     profile = new Profile.Profile()
     {
         Log = log
     };
     database = new Fake.Database(profile);
     database.Connect();
     database.Connection.Open();
 }
Esempio n. 4
0
        public void NormalFullResult()
        {
            var profile  = new Profile.Profile();
            var database = new Fake.Database(profile);

            database.Connect();

            database.Add(new string[3] {
                "Business", "1.2.3", "4"
            });

            Assert.AreEqual("Business1.2.3-4", database.SchemaVersion().ToString());
        }
Esempio n. 5
0
        public void GetSingle()
        {
            var profile  = new Profile.Profile();
            var database = new Fake.Database(profile);

            database.Connect();

            database.Add(new string[2] {
                "Stephen Arthur Jazdzewski", "Steve"
            });

            var individual = new Individual(database, 3);

            Assert.AreEqual(3, individual.Id);
            Assert.AreEqual(true, individual.Person);
            Assert.AreEqual("Steve", individual.GoesBy);
            Assert.AreEqual("Stephen Arthur Jazdzewski", individual.FullName);
        }
Esempio n. 6
0
        public void AuthenticationFailure()
        {
            var log     = new Core.Fake.Log();
            var profile = new Profile.Profile()
            {
                Log = log
            };

            Database = new Fake.Database(profile)
            {
                // Driver specific Exception
                DatabaseException = new System.Exception("Authentication failed")
            };

            Assert.Throws(typeof(System.Exception), new TestDelegate(HostConnectOpenException));

            Assert.That(log.Output, Contains.Substring(Log.Level.Fatal.ToString()));
            Assert.That(log.Output, Contains.Substring("Authentication failed"));
        }
Esempio n. 7
0
        public void ConnectionRefused()
        {
            var log     = new Core.Fake.Log();
            var profile = new Profile.Profile()
            {
                Log = log
            };

            Database = new Fake.Database(profile)
            {
                // Could not resolve host 'hostname'
                // https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
                ConnectionException = new System.Net.Sockets.SocketException(10061)
            };

            Assert.Throws(typeof(System.Net.Sockets.SocketException), new TestDelegate(HostConnectOpenException));

            Assert.That(log.Output, Contains.Substring(Log.Level.Fatal.ToString()));
            Assert.That(log.Output, Contains.Substring("refused"));
        }
Esempio n. 8
0
        public void CantFindTable()
        {
            var log     = new Core.Fake.Log();
            var profile = new Profile.Profile()
            {
                Log = log
            };

            // Driver specific Exception
            Database = new Fake.Database(profile)
            {
                CommandException = new System.Exception("can't find table \"VERSIONS\"")
            };
            Database.Connect();
            Database.Connection.Open();

            Assert.Throws(typeof(System.Exception), new TestDelegate(ExecuteReaderException));

            Assert.That(log.Output, Contains.Substring(Log.Level.Fatal.ToString()));
            Assert.That(log.Output, Contains.Substring("VERSIONS"));
        }
Esempio n. 9
0
        public void Book()
        {
            var profile  = new Profile.Profile();
            var database = new Fake.Database(profile);

            database.Connect();

            var   bookName   = "Sales";
            float bookAmount = 111.11F;
            int?  entryId    = 1;

            database.SetValue(entryId);

            var entry = database.Book(bookName, bookAmount);

            CheckTransaction(database);

            Assert.IsNotNull(entry);
            Assert.Greater(entry, 0);
            Assert.AreEqual(entryId, entry);
        }
Esempio n. 10
0
        public void ReaderGet()
        {
            var log     = new Core.Fake.Log();
            var profile = new Profile.Profile()
            {
                Log = log
            };

            // Driver specific Exception
            Database = new Fake.Database(profile)
            {
                ReaderGetException = new System.Exception("Before start of result set")
            };
            Database.Connect();
            Database.Connection.Open();
            Database.Command.CommandText = "";
            Reader = (Fake.Reader)Database.Command.ExecuteReader();
            Reader.Read();

            Assert.Throws(typeof(System.Exception), new TestDelegate(ReadGetException));

            Assert.That(log.Output, Contains.Substring(Log.Level.Error.ToString()));
            Assert.That(log.Output, Contains.Substring("Before start"));
        }
Esempio n. 11
0
        public void DataReadError()
        {
            var log     = new Core.Fake.Log();
            var profile = new Profile.Profile()
            {
                Log = log
            };
            var database = new Fake.Database(profile)
            {
                // Driver specific Exception
                ReaderGetException = new System.Exception("Before start of result set")
            };

            database.Connect();

            database.Add(new string[3] {
                "Business", "1.2.3", "4"
            });

            Assert.AreEqual("0.0.0-Nil", database.SchemaVersion().ToString());
            Assert.That(log.Output, Contains.Substring(Log.Level.Error.ToString()));
            Assert.That(log.Output, Contains.Substring("Before start"));
            Assert.That(log.Output, Contains.Substring("Version"));
        }