public async Task CreateConnection_Creates_A_Sql_Connection()
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                using (TemporarySqlLocalDbInstance temporary = api.CreateTemporaryInstance(deleteFiles: true))
                {
                    ISqlLocalDbInstanceManager manager = temporary.Manage();

                    manager.ShouldNotBeNull();
                    manager.Name.ShouldBe(temporary.Name);

                    // Act
                    using (SqlConnection actual = manager.CreateConnection())
                    {
                        // Assert
                        actual.ShouldNotBeNull();
                        actual.ConnectionString.ShouldNotBeNull();
                        actual.State.ShouldBe(ConnectionState.Closed);

                        await actual.OpenAsync();

                        actual.Close();
                    }
                }
            }
        }
Exemple #2
0
        public void Restart_Stops_And_Starts_Instance()
        {
            // Arrange
            using var api = new SqlLocalDbApi(_loggerFactory);
            using TemporarySqlLocalDbInstance temporary = api.CreateTemporaryInstance(deleteFiles: true);

            ISqlLocalDbInstanceManager manager = temporary.Manage();

            // Act
            manager.Restart();

            // Assert
            temporary.GetInstanceInfo().IsRunning.ShouldBeTrue();
        }