Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #173

Merged
merged 48 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1ffce96
Bump csharpier from 0.26.2 to 0.26.3
dependabot[bot] Nov 24, 2023
d98125f
Merge pull request #130 from zejji/dependabot/nuget/develop/csharpier…
zejji Nov 24, 2023
e899917
Bump Microsoft.NET.Test.Sdk
dependabot[bot] Dec 11, 2023
10f5a31
Bump xunit.runner.visualstudio from 2.5.4 to 2.5.5
dependabot[bot] Dec 11, 2023
767065d
Bump csharpier from 0.26.3 to 0.26.6
dependabot[bot] Dec 14, 2023
4074ace
Merge pull request #136 from zejji/dependabot/nuget/develop/csharpier…
zejji Dec 14, 2023
208b6fb
Merge pull request #135 from zejji/dependabot/nuget/develop/xunit.run…
zejji Dec 14, 2023
a1217fd
Merge pull request #133 from zejji/dependabot/nuget/develop/Microsoft…
zejji Dec 14, 2023
4e260a6
Bump csharpier from 0.26.6 to 0.26.7
dependabot[bot] Dec 18, 2023
a981c2b
Bump xunit.runner.visualstudio from 2.5.5 to 2.5.6
dependabot[bot] Dec 25, 2023
531c1dd
Bump xunit from 2.6.2 to 2.6.4
dependabot[bot] Dec 25, 2023
550cd04
Merge pull request #137 from zejji/dependabot/nuget/develop/csharpier…
zejji Jan 4, 2024
7e661a2
Merge pull request #138 from zejji/dependabot/nuget/develop/xunit.run…
zejji Jan 4, 2024
597b958
Merge branch 'develop' into dependabot/nuget/develop/xunit-2.6.4
zejji Jan 4, 2024
c39e9a5
Merge pull request #139 from zejji/dependabot/nuget/develop/xunit-2.6.4
zejji Jan 4, 2024
a0d7a46
Bump xunit from 2.6.4 to 2.6.5
dependabot[bot] Jan 5, 2024
924b112
Merge pull request #140 from zejji/dependabot/nuget/develop/xunit-2.6.5
zejji Jan 5, 2024
2213269
Bump Microsoft.NET.Test.Sdk
dependabot[bot] Jan 9, 2024
96e6d3a
Merge pull request #141 from zejji/dependabot/nuget/develop/Microsoft…
zejji Jan 9, 2024
4380e7f
Bump Microsoft.EntityFrameworkCore.Sqlite, Microsoft.EntityFrameworkC…
dependabot[bot] Jan 10, 2024
6392cd4
Bump Microsoft.EntityFrameworkCore.Relational and Microsoft.EntityFra…
dependabot[bot] Jan 10, 2024
e2e45cb
Bump xunit from 2.6.5 to 2.6.6
dependabot[bot] Jan 15, 2024
23086e6
Merge pull request #145 from zejji/dependabot/nuget/develop/xunit-2.6.6
zejji Jan 15, 2024
59fbc73
Merge pull request #143 from zejji/dependabot/nuget/develop/Microsoft…
zejji Jan 15, 2024
17beed1
Merge pull request #142 from zejji/dependabot/nuget/develop/Microsoft…
zejji Jan 15, 2024
b63ba81
Bump csharpier from 0.26.7 to 0.27.0
dependabot[bot] Jan 16, 2024
0388929
Merge pull request #146 from zejji/dependabot/nuget/develop/csharpier…
zejji Jan 23, 2024
ff6f020
Bump csharpier from 0.27.0 to 0.27.1
dependabot[bot] Jan 24, 2024
5496f1d
Merge pull request #147 from zejji/dependabot/nuget/develop/csharpier…
zejji Jan 25, 2024
a4d0045
Bump csharpier from 0.27.1 to 0.27.2
dependabot[bot] Jan 29, 2024
063b598
Merge pull request #148 from zejji/dependabot/nuget/develop/csharpier…
zejji Jan 29, 2024
5810ff6
Bump Microsoft.NET.Test.Sdk from 17.9.0-release-23619-01 to 17.9.0
dependabot[bot] Feb 7, 2024
0478226
Merge pull request #149 from zejji/dependabot/nuget/develop/Microsoft…
zejji Feb 8, 2024
ccac206
Bump Microsoft.EntityFrameworkCore.Sqlite, Microsoft.EntityFrameworkC…
dependabot[bot] Feb 14, 2024
7d1f229
Bump Microsoft.EntityFrameworkCore from 8.0.1 to 8.0.2
dependabot[bot] Feb 14, 2024
55676f3
Bump xunit.runner.visualstudio from 2.5.6 to 2.5.7
dependabot[bot] Feb 16, 2024
f24c0a1
Bump xunit from 2.6.6 to 2.7.0
dependabot[bot] Feb 16, 2024
91673ea
Merge pull request #150 from zejji/dependabot/nuget/develop/Microsoft…
zejji Feb 16, 2024
7b90d1e
Merge pull request #154 from zejji/dependabot/nuget/develop/xunit-2.7.0
zejji Feb 16, 2024
cd5d187
Merge branch 'develop' into dependabot/nuget/develop/xunit.runner.vis…
zejji Feb 16, 2024
931f7ce
Merge pull request #152 from zejji/dependabot/nuget/develop/Microsoft…
zejji Feb 16, 2024
bcb30a9
Bump Microsoft.EntityFrameworkCore.Relational from 8.0.1 to 8.0.2
dependabot[bot] Feb 16, 2024
09e7c6b
Merge pull request #153 from zejji/dependabot/nuget/develop/xunit.run…
zejji Feb 16, 2024
ece1ebe
Merge pull request #155 from zejji/dependabot/nuget/develop/Microsoft…
zejji Feb 16, 2024
7b301c0
Bump csharpier from 0.27.2 to 0.27.3
dependabot[bot] Feb 19, 2024
cf88eec
Merge pull request #156 from zejji/dependabot/nuget/develop/csharpier…
zejji Feb 19, 2024
b0e720c
Merge remote-tracking branch 'origin/main' into develop
zejji Jan 19, 2025
af89d78
Update for EF Core 9
zejji Jan 19, 2025
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
5 changes: 3 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.26.2",
"version": "0.30.6",
"commands": [
"dotnet-csharpier"
]
],
"rollForward": false
}
}
}
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,8 @@ dotnet_diagnostic.SA1633.severity = none
# IDE0063: Use simple 'using' statement
dotnet_diagnostic.IDE0063.severity = none

# IDE0300: Collection initialization can be simplified
dotnet_diagnostic.IDE0300.severity = none

# SA1009: Closing parenthesis should be spaced correctly
dotnet_diagnostic.SA1009.severity = none
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'
dotnet-quality: 'ga'

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'
dotnet-quality: 'ga'
- name: Restore dependencies
run: dotnet restore
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'
dotnet-quality: 'ga'
- name: Restore dependencies
run: dotnet restore
Expand Down
14 changes: 7 additions & 7 deletions DbContextScope.Tests/DbContextScope.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0-alpha.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23531-01" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
110 changes: 55 additions & 55 deletions DbContextScope.Tests/DbContextScopeTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using DbContextScope.Exceptions;
using FluentAssertions;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using DbContextScope.Exceptions;
using Microsoft.EntityFrameworkCore;
using Shouldly;
using Xunit;
using Zejji.Entity;
using Zejji.Tests.Helpers;
Expand All @@ -16,7 +16,7 @@ namespace Zejji.Tests;
public sealed class DbContextScopeTests : IDisposable
{
private readonly SqliteMemoryDatabaseLifetimeManager _databaseManager;
private readonly IDbContextFactory _dbContextFactory;
private readonly TestDbContextFactory _dbContextFactory;
private readonly DbContextScopeFactory _dbContextScopeFactory;

public DbContextScopeTests()
Expand Down Expand Up @@ -52,10 +52,10 @@ public void Nested_scopes_should_use_same_DbContext_by_default()
{
var innerDbContext = innerDbContextScope.DbContexts.Get<TestDbContext>();

outerDbContext.Should().NotBeNull();
innerDbContext.Should().NotBeNull();
outerDbContext.ShouldNotBeNull();
innerDbContext.ShouldNotBeNull();

innerDbContext.Should().BeSameAs(outerDbContext);
innerDbContext.ShouldBeSameAs(outerDbContext);
}
}
}
Expand All @@ -69,8 +69,8 @@ public void Calling_GetRequired_on_an_AmbientDbContextLocator_outside_of_an_ambi
contextLocator.GetRequired<TestDbContext>();
});

ex.Should().NotBeNull();
ex.Should().BeOfType<NoAmbientDbContextScopeException>();
ex.ShouldNotBeNull();
ex.ShouldBeOfType<NoAmbientDbContextScopeException>();
}

[Fact]
Expand Down Expand Up @@ -102,7 +102,7 @@ public void Calling_SaveChanges_on_a_nested_scope_has_no_effect()
using (var dbContext = _dbContextFactory.CreateDbContext<TestDbContext>())
{
var user = dbContext.Users.Single();
user.Name.Should().Be(originalName);
user.Name.ShouldBe(originalName);
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ public void Calling_SaveChanges_on_the_outer_scope_saves_changes()
using (var dbContext = _dbContextFactory.CreateDbContext<TestDbContext>())
{
var user = dbContext.Users.Single();
user.Name.Should().Be(newName);
user.Name.ShouldBe(newName);
}
}

Expand All @@ -154,8 +154,8 @@ public void Changes_can_only_be_saved_once_on_a_DbContextScope()
});

// Assert - an InvalidOperationException should have been thrown
ex.Should().NotBeNull();
ex.Should().BeOfType<InvalidOperationException>();
ex.ShouldNotBeNull();
ex.ShouldBeOfType<InvalidOperationException>();
}
}

Expand Down Expand Up @@ -227,11 +227,11 @@ public void SaveChanges_can_be_called_again_after_a_DbUpdateConcurrencyException
}

// Assert
concurrencyExceptionThrown.Should().Be(true);
concurrencyExceptionThrown.ShouldBe(true);
using (var dbContext = _dbContextFactory.CreateDbContext<TestDbContext>())
{
var user = dbContext.Users.Single();
user.Name.Should().Be(newName2);
user.Name.ShouldBe(newName2);
}
}

Expand All @@ -246,7 +246,7 @@ public void IDbContextReadOnlyScope_should_not_have_SaveChanges_method()
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly
);
var saveChangesMethod = publicMethods.SingleOrDefault(m => m.Name == "SaveChanges");
saveChangesMethod.Should().BeNull();
saveChangesMethod.ShouldBeNull();
}
}

Expand All @@ -260,8 +260,8 @@ public void AmbientDbContextLocator_should_return_ambient_scope()
var contextLocator = new AmbientDbContextLocator();
var ambientDbContext = contextLocator.Get<TestDbContext>();

ambientDbContext.Should().NotBeNull();
ambientDbContext.Should().BeSameAs(dbContext);
ambientDbContext.ShouldNotBeNull();
ambientDbContext.ShouldBeSameAs(dbContext);
}
}

Expand All @@ -280,10 +280,10 @@ public void ForceCreateNew_option_should_create_new_DbContext_in_nested_scope()
{
var innerDbContext = innerDbContextScope.DbContexts.Get<TestDbContext>();

outerDbContext.Should().NotBeNull();
innerDbContext.Should().NotBeNull();
outerDbContext.ShouldNotBeNull();
innerDbContext.ShouldNotBeNull();

innerDbContext.Should().NotBeSameAs(outerDbContext);
innerDbContext.ShouldNotBeSameAs(outerDbContext);
}
}
}
Expand Down Expand Up @@ -311,7 +311,7 @@ public void RefreshEntitiesInParentScope_should_reload_changed_data_from_databas
var outerDbContext = outerDbContextScope.DbContexts.Get<TestDbContext>();
var outerUsers = outerDbContext.Users.ToList();

outerUsers.Count.Should().Be(2);
outerUsers.Count.ShouldBe(2);

// Arrange - modify the entity in an inner scope created with ForceCreateNew
using (
Expand All @@ -329,15 +329,15 @@ public void RefreshEntitiesInParentScope_should_reload_changed_data_from_databas

// Entities in outer scope should be unchanged at this point
// since we have not refreshed the entities yet
outerUsers[0].Name.Should().Be(originalName1);
outerUsers[1].Name.Should().Be(originalName2);
outerUsers[0].Name.ShouldBe(originalName1);
outerUsers[1].Name.ShouldBe(originalName2);

// Act - only refresh first user in parent scope, but not the second
innerDbContextScope.RefreshEntitiesInParentScope(new User[] { innerUsers[0] });

// Assert
outerUsers[0].Name.Should().Be(newName1);
outerUsers[1].Name.Should().Be(originalName2);
outerUsers[0].Name.ShouldBe(newName1);
outerUsers[1].Name.ShouldBe(originalName2);
}
}
}
Expand All @@ -358,16 +358,16 @@ public void RefreshEntitiesInParentScope_should_refresh_entities_with_composite_
CoursesUsers = new CourseUser[]
{
new() { Course = course1, Grade = "A" },
new() { Course = course2, Grade = "C" }
}
new() { Course = course2, Grade = "C" },
},
},
new()
{
Name = "Test User 2",
CoursesUsers = new CourseUser[]
{
new() { Course = course1, Grade = "F" }
}
new() { Course = course1, Grade = "F" },
},
}
);
dbContext.SaveChanges();
Expand All @@ -376,12 +376,12 @@ public void RefreshEntitiesInParentScope_should_refresh_entities_with_composite_
using (var outerDbContextScope = _dbContextScopeFactory.Create())
{
var outerDbContext = outerDbContextScope.DbContexts.Get<TestDbContext>();
var outerUsers = outerDbContext.Users
.Include(u => u.CoursesUsers)
var outerUsers = outerDbContext
.Users.Include(u => u.CoursesUsers)
.ThenInclude(cu => cu.Course)
.ToList();

outerUsers.Count.Should().Be(2);
outerUsers.Count.ShouldBe(2);

// Arrange(2) - modify the CourseUser entities in an inner scope created with ForceCreateNew
using (
Expand All @@ -391,8 +391,8 @@ public void RefreshEntitiesInParentScope_should_refresh_entities_with_composite_
)
{
var innerDbContext = innerDbContextScope.DbContexts.Get<TestDbContext>();
var innerUsers = innerDbContext.Users
.Include(u => u.CoursesUsers)
var innerUsers = innerDbContext
.Users.Include(u => u.CoursesUsers)
.ThenInclude(cu => cu.Course)
.ToList();

Expand All @@ -408,11 +408,11 @@ public void RefreshEntitiesInParentScope_should_refresh_entities_with_composite_
// Entities in outer scope should be unchanged at this point
// since we have not refreshed the entities yet
var outerUser1CoursesUsers = outerUsers[0].CoursesUsers.ToList();
outerUser1CoursesUsers[0].Grade.Should().Be("A");
outerUser1CoursesUsers[1].Grade.Should().Be("C");
outerUser1CoursesUsers[0].Grade.ShouldBe("A");
outerUser1CoursesUsers[1].Grade.ShouldBe("C");

var outerUser2CoursesUsers = outerUsers[1].CoursesUsers.ToList();
outerUser2CoursesUsers[0].Grade.Should().Be("F");
outerUser2CoursesUsers[0].Grade.ShouldBe("F");

// Act - only refresh the first user's CoursesUsers in the parent scope,
// but NOT the second user's
Expand All @@ -421,9 +421,9 @@ public void RefreshEntitiesInParentScope_should_refresh_entities_with_composite_
);

// Assert
outerUser1CoursesUsers[0].Grade.Should().Be("B"); // new value
outerUser1CoursesUsers[1].Grade.Should().Be("D"); // new value
outerUser2CoursesUsers[0].Grade.Should().Be("F"); // unchanged from original value
outerUser1CoursesUsers[0].Grade.ShouldBe("B"); // new value
outerUser1CoursesUsers[1].Grade.ShouldBe("D"); // new value
outerUser2CoursesUsers[0].Grade.ShouldBe("F"); // unchanged from original value
}
}
}
Expand All @@ -433,11 +433,11 @@ public void Calling_SuppressAmbientContext_should_suppress_ambient_DbContextScop
{
using (var dbContextScope = _dbContextScopeFactory.Create())
{
dbContextScope.Should().NotBeNull();
dbContextScope.ShouldNotBeNull();

var outerAmbientContextLocator = new AmbientDbContextLocator();
var outerContext1 = outerAmbientContextLocator.Get<TestDbContext>();
outerContext1.Should().NotBeNull();
outerContext1.ShouldNotBeNull();

using (var suppressor = _dbContextScopeFactory.SuppressAmbientContext())
{
Expand All @@ -446,24 +446,24 @@ public void Calling_SuppressAmbientContext_should_suppress_ambient_DbContextScop
// Since we have suppressed the ambient DbContextScope here, we should
// not be able to get a DbContext from the innerAmbientContextLocator
var suppressedContext = suppressedAmbientContextLocator.Get<TestDbContext>();
suppressedContext.Should().BeNull();
suppressedContext.ShouldBeNull();

// And any new DbContextScope should not join the existing one
using (var innerDbContextScope = _dbContextScopeFactory.Create())
{
innerDbContextScope.Should().NotBeNull();
innerDbContextScope.ShouldNotBeNull();

var innerAmbientContextLocator = new AmbientDbContextLocator();
var innerContext = innerAmbientContextLocator.Get<TestDbContext>();
innerContext.Should().NotBeNull();
innerContext.Should().NotBeSameAs(outerContext1);
innerContext.ShouldNotBeNull();
innerContext.ShouldNotBeSameAs(outerContext1);
}
}

// The original ambient DbContextScope should be restored here
var outerContext2 = outerAmbientContextLocator.Get<TestDbContext>();
outerContext1.Should().NotBeNull();
outerContext2.Should().BeSameAs(outerContext1);
outerContext1.ShouldNotBeNull();
outerContext2.ShouldBeSameAs(outerContext1);
}
}

Expand All @@ -485,13 +485,13 @@ public void Multiple_threads_which_create_a_DbContextScope_use_separate_DbContex
{
using (var dbContextScope = _dbContextScopeFactory.Create())
{
dbContextScope.Should().NotBeNull();
dbContextScope.ShouldNotBeNull();

var dbContextScopeId = dbContextScope.GetHashCode();
dbContextScopeIds.Add(dbContextScopeId);

var dbContext = dbContextScope.DbContexts.Get<TestDbContext>();
dbContext.Should().NotBeNull();
dbContext.ShouldNotBeNull();

var dbContextId = dbContext.GetHashCode();
dbContextIds.Add(dbContextId);
Expand All @@ -500,10 +500,10 @@ public void Multiple_threads_which_create_a_DbContextScope_use_separate_DbContex
);

// We should have a unique DbContextScope and DbContext for each thread
dbContextScopeIds.Count.Should().Be(threadCount);
dbContextIds.Count.Should().Be(threadCount);
dbContextScopeIds.Count.ShouldBe(threadCount);
dbContextIds.Count.ShouldBe(threadCount);

dbContextScopeIds.Should().OnlyHaveUniqueItems();
dbContextIds.Should().OnlyHaveUniqueItems();
dbContextScopeIds.ShouldBeUnique();
dbContextIds.ShouldBeUnique();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Data.Sqlite;
using System;
using System;
using System.Data.Common;
using Microsoft.Data.Sqlite;

namespace Zejji.Tests.Helpers
{
Expand Down
Loading
Loading