Skip to content

Commit

Permalink
Changed default for SaveChanges during dispose to "false"
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed Dec 17, 2021
1 parent 3482a74 commit 59ea64d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions FubarDev.UnitOfWork.Tests/NonTransactionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// </copyright>

using System;
using System.Linq;
using System.Threading.Tasks;

using FubarDev.UnitOfWork.Tests.Support;
Expand Down Expand Up @@ -58,7 +59,7 @@ public async Task TestDisposeAsync()
}

Assert.Contains(repositoryId, _repositoryManager.Creations);
Assert.Equal(1, _repositoryManager.SavedChangesCount);
Assert.Equal(0, _repositoryManager.SavedChangesCount);
Assert.Equal(1, _repositoryManager.DisposedRepositories);
}

Expand All @@ -77,7 +78,7 @@ public async Task TestNestedAsync()

Assert.Equal(repositoryId1, repositoryId2);
Assert.Equal(repositoryId1, Assert.Single(_repositoryManager.Creations));
Assert.Equal(2, _repositoryManager.SavedChangesCount);
Assert.Equal(0, _repositoryManager.SavedChangesCount);
Assert.Equal(1, _repositoryManager.DisposedRepositories);
}
}
Expand Down
4 changes: 2 additions & 2 deletions FubarDev.UnitOfWork.Tests/TransactionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task TestNestedWithNonTransactionalAsync()

Assert.Equal(repositoryId1, repositoryId2);
Assert.Equal(repositoryId1, Assert.Single(_repositoryManager.Creations));
Assert.Equal(1, _repositoryManager.SavedChangesCount);
Assert.Equal(0, _repositoryManager.SavedChangesCount);
Assert.Contains(repositoryId1, _repositoryManager.Commits);
Assert.Contains(repositoryId1, _repositoryManager.Rollbacks);
Assert.Equal(0, _repositoryManager.CommitCount);
Expand Down Expand Up @@ -196,7 +196,7 @@ public async Task TestNestedWithNonTransactionalInWrongOrderAsync()

Assert.Equal(repositoryId1, repositoryId2);
Assert.Equal(repositoryId1, Assert.Single(_repositoryManager.Creations));
Assert.Equal(1, _repositoryManager.SavedChangesCount);
Assert.Equal(0, _repositoryManager.SavedChangesCount);
Assert.Contains(repositoryId1, _repositoryManager.Commits);
Assert.Contains(repositoryId1, _repositoryManager.Rollbacks);
Assert.Equal(0, _repositoryManager.CommitCount);
Expand Down
2 changes: 1 addition & 1 deletion FubarDev.UnitOfWork/UnitOfWorkFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public UnitOfWorkFactory(
IOptions<UnitOfWorkFactoryOptions>? options = null)
{
_allowNestedTransactions = options?.Value.AllowNestedTransactions ?? false;
_saveChangesOnDispose = options?.Value.SaveChangesWhenDisposingUnitOfWork ?? true;
_saveChangesOnDispose = options?.Value.SaveChangesWhenDisposingUnitOfWork ?? false;
_repositoryManager = repositoryManager;
_logger = logger;
_statusManager = new DefaultStatusManager<UnitOfWorkStatusItem<TRepository>>(
Expand Down

0 comments on commit 59ea64d

Please sign in to comment.