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")); }
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")); }
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")); }
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")); }
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")); }