示例#1
0
        public void ConnectionTypeTest()
        {
            var dataOptions = new PostgresDataOptions();

            dataOptions.ConnectionString = "Host=localhost;";

            Assert.IsType <NpgsqlConnection>(dataOptions.CreateConnection());
        }
示例#2
0
        public void ShouldRetryTest()
        {
            var dataOptions = new PostgresDataOptions();

            dataOptions.ConnectionString = "Host=localhost;";

            var mockServerEx      = new NpgsqlException();
            var postgresEx        = new PostgresException();
            var generalEx         = new Exception("some error");
            var anotherSpecificEx = new AggregateException("some aggregated error");

            // Should retry only on server specific errors
            Assert.True(dataOptions.ShouldRetryOn(mockServerEx));

            // Otherwise, should not retry
            Assert.False(dataOptions.ShouldRetryOn(postgresEx));
            Assert.False(dataOptions.ShouldRetryOn(generalEx));
            Assert.False(dataOptions.ShouldRetryOn(anotherSpecificEx));
        }