From 1604ed450510bd3412caf4ae398d32b736fe44a0 Mon Sep 17 00:00:00 2001 From: frblondin Date: Fri, 24 Mar 2023 13:45:41 +0100 Subject: [PATCH] Improve unit tests by disposing connection to avoid locked temporary files [skip release notes] --- .../Commands/CommitCommandTests.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tests/GitObjectDb.Tests/Commands/CommitCommandTests.cs b/src/tests/GitObjectDb.Tests/Commands/CommitCommandTests.cs index 275748c7..1196d428 100644 --- a/src/tests/GitObjectDb.Tests/Commands/CommitCommandTests.cs +++ b/src/tests/GitObjectDb.Tests/Commands/CommitCommandTests.cs @@ -29,7 +29,7 @@ public void AddNewNodeUsingNodeFolders(IFixture fixture, Application application var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -54,7 +54,7 @@ public void AddNewNodeWithoutNodeFolders(IFixture fixture, Table table, UniqueId var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -79,7 +79,7 @@ public void AddNewResource(IFixture fixture, Table table, string fileContent, st var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); var resource = new Resource(table, "Some/Folder", "File.txt", new Resource.Data(fileContent)); // Act @@ -107,7 +107,7 @@ public void DeletingNodeRemovesNestedChildren(IFixture fixture, Table table, str var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -130,7 +130,7 @@ public void RenamingNonGitFoldersIsSupported(IFixture fixture, Field field, stri var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -156,7 +156,7 @@ public void RenamingGitFoldersIsNotSupported(IFixture fixture, Table table, stri var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -174,7 +174,7 @@ public void EditNestedProperty(IFixture fixture, Field field, string message, Si var comparer = fixture.Create(); var gitUpdateCommand = fixture.Create(); var sut = fixture.Create(); - var connection = fixture.Create(); + using var connection = fixture.Create(); // Act var composer = new TransformationComposer(connection, "main", gitUpdateCommand, sut); @@ -215,6 +215,7 @@ public void Customize(IFixture fixture) A.CallTo(() => connection.Model).Returns(fixture.Create()); A.CallTo(() => connection.Serializer).Returns(fixture.Create()); A.CallTo(() => connection.Cache).Returns(fixture.Create()); + A.CallTo(() => connection.Dispose()).DoesNothing(); fixture.Inject(connection); var validation = A.Fake(x => x.Strict());