forked from icgam/Easify.Ef
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit of the fix for dependencies * port from Easify and merge with EF core project * Added icon for the packages
- Loading branch information
1 parent
d55abe9
commit f85601a
Showing
55 changed files
with
2,567 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
next-version: 1.0.0 | ||
mode: Mainline | ||
major-version-bump-message: '\+semver:\s?(breaking|major)' | ||
minor-version-bump-message: '\+semver:\s?(feature|minor)' | ||
patch-version-bump-message: '\+semver:\s?(fix|patch)' | ||
no-bump-message: '\+semver:\s?(none|skip)' | ||
ignore: | ||
commits-before: 2023-01-01T00:00:00 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests.Entities | ||
{ | ||
public class City | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public int CountryId { get; set; } | ||
public Country Country { get; set; } | ||
public List<Town> Towns { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/LittleBlocks.Ef.UnitOfWork.UnitTests/Entities/Country.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests.Entities | ||
{ | ||
public class Country | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
|
||
public List<City> Cities { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/LittleBlocks.Ef.UnitOfWork.UnitTests/Entities/Customer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests.Entities | ||
{ | ||
public class Customer | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public int Age { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests.Entities | ||
{ | ||
public class Town | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public int CityId { get; set; } | ||
public City City { get; set; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/LittleBlocks.Ef.UnitOfWork.UnitTests/InMemoryDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using LittleBlocks.Ef.UnitOfWork.UnitTests.Entities; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests | ||
{ | ||
public class InMemoryDbContext : DbContext | ||
{ | ||
public DbSet<Country> Countries { get; set; } | ||
public DbSet<Customer> Customers { get; set; } | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
var name = $"{typeof(InMemoryDbContext).Name}_{Guid.NewGuid()}"; | ||
|
||
var serviceProvider = new ServiceCollection() | ||
.AddEntityFrameworkInMemoryDatabase() | ||
.BuildServiceProvider(); | ||
optionsBuilder.UseInMemoryDatabase(name) | ||
.ConfigureWarnings(warnings => warnings.Ignore(InMemoryEventId.TransactionIgnoredWarning)) | ||
.UseInternalServiceProvider(serviceProvider); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/LittleBlocks.Ef.UnitOfWork.UnitTests/LittleBlocks.Ef.UnitOfWork.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
<Authors>Mohammad Moattar</Authors> | ||
<Company>LittleBlocks</Company> | ||
<Description>LittleBlocks support for entity framework core and UnitOfWork</Description> | ||
<PackageProjectUrl>https://github.com/LittleBlocks/LittleBlocks.Ef</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/LittleBlocks/LittleBlocks.Ef</RepositoryUrl> | ||
<Version>1.0.0</Version> | ||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.8.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.12" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LittleBlocks.Ef.UnitOfWork\LittleBlocks.Ef.UnitOfWork.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
50 changes: 50 additions & 0 deletions
50
src/LittleBlocks.Ef.UnitOfWork.UnitTests/RepositoryFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using LittleBlocks.Ef.UnitOfWork.UnitTests.Entities; | ||
|
||
namespace LittleBlocks.Ef.UnitOfWork.UnitTests | ||
{ | ||
public class RepositoryFixture | ||
{ | ||
private static IEnumerable<Country> TestCountries => new List<Country> | ||
{ | ||
new Country {Id = 1, Name = "A"}, | ||
new Country {Id = 2, Name = "B"} | ||
}; | ||
|
||
private static IEnumerable<City> TestCities => new List<City> | ||
{ | ||
new City { Id = 1, Name = "A", CountryId = 1}, | ||
new City { Id = 2, Name = "B", CountryId = 2}, | ||
new City { Id = 3, Name = "C", CountryId = 1}, | ||
new City { Id = 4, Name = "D", CountryId = 2}, | ||
new City { Id = 5, Name = "E", CountryId = 1}, | ||
new City { Id = 6, Name = "F", CountryId = 2}, | ||
}; | ||
|
||
private static IEnumerable<Town> TestTowns => new List<Town> | ||
{ | ||
new Town { Id = 1, Name="A", CityId = 1 }, | ||
new Town { Id = 2, Name="B", CityId = 2 }, | ||
new Town { Id = 3, Name="C", CityId = 3 }, | ||
new Town { Id = 4, Name="D", CityId = 4 }, | ||
new Town { Id = 5, Name="E", CityId = 5 }, | ||
new Town { Id = 6, Name="F", CityId = 6 }, | ||
}; | ||
|
||
public InMemoryDbContext DbContext() | ||
{ | ||
var dbContext = new InMemoryDbContext(); | ||
|
||
dbContext.AddRange(TestCountries); | ||
dbContext.AddRange(TestCities); | ||
dbContext.AddRange(TestTowns); | ||
|
||
dbContext.SaveChanges(); | ||
|
||
return dbContext; | ||
} | ||
|
||
public IUnitOfWork CreateUnitOfWork() => new UnitOfWork<InMemoryDbContext>(DbContext()); | ||
|
||
public IRepository<T> CreateRepository<T>() where T : class => new Repository<T>(DbContext()); | ||
} | ||
} |
Oops, something went wrong.