Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion DuckDB.NET.Test/DuckDBConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ public async Task CloseCanBeCalledMoreThanOnce()
stateChanges.Should().Be(1, "only the first Close changes the state");
}

[Fact]
[Trait("Category", "Baseline")]
public async Task CloseNeverOpenedConnectionDoesNotThrow()
{
await using var duckDBConnection = new DuckDBConnection("DataSource=:memory:");
var stateChanges = 0;
duckDBConnection.StateChange += (_, _) => stateChanges++;

duckDBConnection.Close();
await duckDBConnection.CloseAsync();

duckDBConnection.State.Should().Be(ConnectionState.Closed);
stateChanges.Should().Be(0, "a connection that was never opened does not change state");
}

[Fact]
[Trait("Category", "Baseline")]
public async Task CloseAfterDisposeDoesNotThrow()
Expand Down Expand Up @@ -552,4 +567,4 @@ public void ConnectionSetsDuckDBApiConfigOption()
value.Should().StartWith("DuckDB.NET");
}
}
}
}
Loading