Exemple #1
0
        public void IsDatabaseConnectionPossible_returns_false_if_connection_string_is_null(IConnectionStringProvider connectionStringProvider,
                                                                                            IPerformsDatabaseUpgrades upgrader,
                                                                                            ILog logger)
        {
            // Arrange
            Mock.Get(connectionStringProvider).Setup(x => x.GetConnectionStringSettings()).Returns(() => null);
            var sut = new SqliteDatabaseTester(new Lazy <IConnectionStringProvider>(() => connectionStringProvider),
                                               new Lazy <IPerformsDatabaseUpgrades>(() => upgrader),
                                               logger);

            // Act
            var result = sut.IsDatabaseConnectionPossible();

            // Assert
            Assert.That(result, Is.False);
        }
Exemple #2
0
        public void IsDatabaseConnectionPossible_returns_true_if_connection_string_is_valid(IConnectionStringProvider connectionStringProvider,
                                                                                            IPerformsDatabaseUpgrades upgrader,
                                                                                            ILog logger)
        {
            // Arrange
            var dataSource       = validDbPath;
            var connectionString = GetSqliteConnectionString(dataSource);

            Mock.Get(connectionStringProvider)
            .Setup(x => x.GetConnectionStringSettings())
            .Returns(() => new ConnectionStringSettings(ConnStringName, connectionString, providerName));
            var sut = new SqliteDatabaseTester(new Lazy <IConnectionStringProvider>(() => connectionStringProvider),
                                               new Lazy <IPerformsDatabaseUpgrades>(() => upgrader),
                                               logger);

            // Act
            var result = sut.IsDatabaseConnectionPossible();

            // Assert
            Assert.That(result, Is.True);
        }
Exemple #3
0
        public void IsDatabaseConnectionPossible_returns_false_if_connection_string_is_invalid(IConnectionStringProvider connectionStringProvider,
                                                                                               IPerformsDatabaseUpgrades upgrader,
                                                                                               ILog logger)
        {
            // Arrange
            // Note that this assumption would fail for Mono on Windows, but not important enough to over-engineer
            var dataSource = invalidDbPath;
            var invalidConnectionString = GetSqliteConnectionString(dataSource);

            Mock.Get(connectionStringProvider)
            .Setup(x => x.GetConnectionStringSettings())
            .Returns(() => new ConnectionStringSettings(ConnStringName, invalidConnectionString, providerName));
            var sut = new SqliteDatabaseTester(new Lazy <IConnectionStringProvider>(() => connectionStringProvider),
                                               new Lazy <IPerformsDatabaseUpgrades>(() => upgrader),
                                               logger);

            // Act
            var result = sut.IsDatabaseConnectionPossible();

            // Assert
            Assert.That(result, Is.False);
        }