├── googlea6bd68d4a55b1e59.html
├── src
├── EntityFrameworkCore.Testing.Common.Tests
│ ├── TestEntity.cs
│ ├── NotRegisteredEntity.cs
│ ├── TestReadOnlyEntity.cs
│ ├── TestViewModel.cs
│ ├── MappingProfile.cs
│ ├── BaseTestEntity.cs
│ ├── BaseForTests.cs
│ ├── AsyncEnumerableTests.cs
│ ├── Issue114Tests.cs
│ ├── Issue126Tests.cs
│ ├── TestDbContext.cs
│ ├── Issue49Tests.cs
│ ├── EntityFrameworkCore.Testing.Common.Tests.csproj
│ ├── Issue117Tests.cs
│ ├── Issue88Tests.cs
│ ├── BaseForDbSetTests.cs
│ ├── BaseForReadOnlyDbSetTests.cs
│ └── ReadOnlyDbSetExceptionTests.cs
├── EntityFrameworkCore.Testing.Moq.Tests
│ ├── Issue114Tests.cs
│ ├── Issue117Tests.cs
│ ├── ByPropertyDbSetTests.cs
│ ├── ByTypeReadOnlyDbSetTests.cs
│ ├── ByPropertyReadOnlyDbSetTests.cs
│ ├── Issue49Tests.cs
│ ├── DbContextTestsUsingType.cs
│ ├── DbContextTestsUsingConstructorParameters.cs
│ ├── Issue126Tests.cs
│ ├── Issue88Tests.cs
│ ├── ByTypeReadOnlyDbSetExceptionTests.cs
│ ├── ByPropertyReadOnlyDbSetExceptionTests.cs
│ ├── ByTypeDbSetTests.cs
│ ├── EntityFrameworkCore.Testing.Moq.Tests.csproj
│ ├── CreateFactoryTests.cs
│ ├── BaseForDbContextTests.cs
│ ├── BaseForDbSetTests.cs
│ ├── Issue1Tests.cs
│ ├── Issue4Tests.cs
│ ├── Issue6Tests.cs
│ └── BaseForDbQueryTests.cs
├── EntityFrameworkCore.Testing.NSubstitute.Tests
│ ├── Issue114Tests.cs
│ ├── Issue117Tests.cs
│ ├── ByPropertyDbSetTests.cs
│ ├── ByTypeReadOnlyDbSetTests.cs
│ ├── ByPropertyReadOnlyDbSetTests.cs
│ ├── Issue49Tests.cs
│ ├── DbContextTestsUsingType.cs
│ ├── DbContextTestsUsingConstructorParameters.cs
│ ├── Issue126Tests.cs
│ ├── Issue88Tests.cs
│ ├── ByTypeReadOnlyDbSetExceptionTests.cs
│ ├── ByPropertyReadOnlyDbSetExceptionTests.cs
│ ├── ByTypeDbSetTests.cs
│ ├── EntityFrameworkCore.Testing.NSubstitute.Tests.csproj
│ ├── CreateFactoryTests.cs
│ ├── BaseForDbContextTests.cs
│ ├── BaseForDbSetTests.cs
│ ├── Issue1Tests.cs
│ ├── Issue4Tests.cs
│ ├── Issue6Tests.cs
│ └── BaseForDbQueryTests.cs
├── EntityFrameworkCore.DefaultBehaviour.Tests
│ ├── Issue114Tests.cs
│ ├── Issue117Tests.cs
│ ├── Issue49Tests.cs
│ ├── ByTypeReadOnlyDbSetExceptionTests.cs
│ ├── Issue88Tests.cs
│ ├── EntityFrameworkCore.DefaultBehaviour.Tests.csproj
│ ├── ByTypeReadOnlyDbSetTests.cs
│ ├── DbContextTests.cs
│ └── ByTypeDbSetTests.cs
├── EntityFrameworkCore.Testing.Common
│ ├── QueryRootExpression.cs
│ ├── AsyncEnumerator.cs
│ ├── Helpers
│ │ ├── MockedDbContextFactoryOptions.cs
│ │ ├── IMockedDbContextBuilder.cs
│ │ ├── BaseMockedDbContextBuilder.cs
│ │ ├── BaseMockedDbContextFactory.cs
│ │ ├── ExpressionHelper.cs
│ │ └── ParameterMatchingHelper.cs
│ ├── AsyncEnumerable.cs
│ ├── EntityFrameworkCore.Testing.Common.csproj
│ ├── ExceptionMessages.Designer.cs
│ ├── AsyncQueryProvider.cs
│ └── ExceptionMessages.resx
├── EntityFrameworkCore.Testing.Moq
│ ├── Helpers
│ │ └── MockedDbContextBuilder.cs
│ ├── EntityFrameworkCore.Testing.Moq.csproj
│ ├── Extensions
│ │ ├── QueryProviderExtensions.Internal.cs
│ │ ├── ReadOnlyDbSetExtensions.cs
│ │ ├── DbSetExtensions.Internal.cs
│ │ └── QueryableExtensions.cs
│ └── Create.cs
└── EntityFrameworkCore.Testing.NSubstitute
│ ├── Helpers
│ ├── MockedDbContextBuilder.cs
│ └── NoSetUpHandler.cs
│ ├── EntityFrameworkCore.Testing.NSubstitute.csproj
│ ├── Extensions
│ ├── QueryProviderExtensions.Internal.cs
│ ├── ReadOnlyDbSetExtensions.cs
│ ├── DbSetExtensions.Internal.cs
│ └── QueryableExtensions.cs
│ └── Create.cs
├── TODO.md
├── LICENSE
├── .github
└── workflows
│ ├── release.yml
│ └── continuous-integration-checks.yml
├── EntityFrameworkCore.Testing.Moq.nuspec
├── EntityFrameworkCore.Testing.NSubstitute.nuspec
├── EntityFrameworkCore.Testing.sln
└── .gitignore
/googlea6bd68d4a55b1e59.html:
--------------------------------------------------------------------------------
1 | google-site-verification: googlea6bd68d4a55b1e59.html
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/TestEntity.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.Common.Tests
2 | {
3 | public class TestEntity : BaseTestEntity { }
4 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/NotRegisteredEntity.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.Common.Tests
2 | {
3 | public class NotRegisteredEntity : BaseTestEntity { }
4 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/TestReadOnlyEntity.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.Common.Tests
2 | {
3 | public class TestReadOnlyEntity : BaseTestEntity { }
4 | }
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | - Add tests for untested functionality
4 | - Remove repeated set up code
5 | - Unify test structures to assist with cross project comparisons
6 | - Add default behaviour tests for SQL Server provider
7 |
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/TestViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EntityFrameworkCore.Testing.Common.Tests
4 | {
5 | public class TestViewModel
6 | {
7 | public Guid id { get; set; }
8 |
9 | public string fullName { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/Issue114Tests.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.Moq.Tests
2 | {
3 | public class Issue114Tests : Common.Tests.Issue114Tests
4 | {
5 | protected override TestDbContext MockedDbContextFactory()
6 | {
7 | return Create.MockedDbContextFor();
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/Issue117Tests.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.Moq.Tests
2 | {
3 | public class Issue117Tests : Common.Tests.Issue117Tests
4 | {
5 | protected override TestDbContext MockedDbContextFactory()
6 | {
7 | return Create.MockedDbContextFor();
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/Issue114Tests.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
2 | {
3 | public class Issue114Tests : Common.Tests.Issue114Tests
4 | {
5 | protected override TestDbContext MockedDbContextFactory()
6 | {
7 | return Create.MockedDbContextFor();
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/Issue117Tests.cs:
--------------------------------------------------------------------------------
1 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
2 | {
3 | public class Issue117Tests : Common.Tests.Issue117Tests
4 | {
5 | protected override TestDbContext MockedDbContextFactory()
6 | {
7 | return Create.MockedDbContextFor();
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/ByPropertyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Tests
5 | {
6 | public class ByPropertyDbSetTests : BaseForDbSetTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.TestEntities;
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/MappingProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace EntityFrameworkCore.Testing.Common.Tests
4 | {
5 | public class MappingProfile : Profile
6 | {
7 | public MappingProfile()
8 | {
9 | CreateMap();
10 |
11 | CreateMap();
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByPropertyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
5 | {
6 | public class ByPropertyDbSetTests : BaseForDbSetTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.TestEntities;
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/ByTypeReadOnlyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Tests
5 | {
6 | public class ByTypeReadOnlyDbSetTests : BaseForDbQueryTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.Set();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/ByPropertyReadOnlyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Tests
5 | {
6 | public class ByPropertyReadOnlyDbSetTests : BaseForDbQueryTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.Set();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByTypeReadOnlyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
5 | {
6 | public class ByTypeReadOnlyDbSetTests : BaseForDbQueryTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.Set();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByPropertyReadOnlyDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
5 | {
6 | public class ByPropertyReadOnlyDbSetTests : BaseForDbQueryTests
7 | {
8 | protected override IQueryable Queryable => MockedDbContext.Set();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/Issue49Tests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using NUnit.Framework;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Tests
5 | {
6 | public class Issue49Tests : Issue49Tests
7 | {
8 | [SetUp]
9 | public override void SetUp()
10 | {
11 | base.SetUp();
12 |
13 | DbContext = Create.MockedDbContextFor();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/Issue49Tests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using NUnit.Framework;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
5 | {
6 | public class Issue49Tests : Issue49Tests
7 | {
8 | [SetUp]
9 | public override void SetUp()
10 | {
11 | base.SetUp();
12 |
13 | DbContext = Create.MockedDbContextFor();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/DbContextTestsUsingType.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using NUnit.Framework;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Tests
5 | {
6 | public class DbContextTestsUsingType : BaseForDbContextTests
7 | {
8 | [SetUp]
9 | public override void SetUp()
10 | {
11 | base.SetUp();
12 |
13 | MockedDbContext = Create.MockedDbContextFor();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.DefaultBehaviour.Tests/Issue114Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace EntityFrameworkCore.DefaultBehaviour.Tests
5 | {
6 | public class Issue114Tests : Testing.Common.Tests.Issue114Tests
7 | {
8 | protected override TestDbContext MockedDbContextFactory()
9 | {
10 | return new TestDbContext(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.DefaultBehaviour.Tests/Issue117Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace EntityFrameworkCore.DefaultBehaviour.Tests
5 | {
6 | public class Issue117Tests : Testing.Common.Tests.Issue117Tests
7 | {
8 | protected override TestDbContext MockedDbContextFactory()
9 | {
10 | return new TestDbContext(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/DbContextTestsUsingType.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using NUnit.Framework;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
5 | {
6 | public class DbContextTestsUsingType : BaseForDbContextTests
7 | {
8 | [SetUp]
9 | public override void SetUp()
10 | {
11 | base.SetUp();
12 |
13 | MockedDbContext = Create.MockedDbContextFor();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/BaseTestEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EntityFrameworkCore.Testing.Common.Tests
4 | {
5 | public abstract class BaseTestEntity
6 | {
7 | public Guid Id { get; set; }
8 |
9 | public string FullName { get; set; }
10 |
11 | public decimal Weight { get; set; }
12 |
13 | public decimal Height { get; set; }
14 |
15 | public DateTime DateOfBirth { get; set; }
16 |
17 | public DateTime CreatedAt { get; set; }
18 |
19 | public DateTime LastModifiedAt { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.DefaultBehaviour.Tests/Issue49Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.DefaultBehaviour.Tests
7 | {
8 | public class Issue49Tests : Issue49Tests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | DbContext = new TestDbContext(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common/QueryRootExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using Microsoft.EntityFrameworkCore.Metadata;
4 | using Microsoft.EntityFrameworkCore.Query;
5 |
6 | namespace EntityFrameworkCore.Testing.Common
7 | {
8 | public class FakeQueryRootExpression : EntityQueryRootExpression
9 | {
10 | public FakeQueryRootExpression(IAsyncQueryProvider asyncQueryProvider, IEntityType entityType) : base(asyncQueryProvider, entityType)
11 | {
12 | Type = typeof(IOrderedQueryable<>).MakeGenericType(entityType.ClrType);
13 | }
14 |
15 | public override Type Type { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/DbContextTestsUsingConstructorParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.Moq.Tests
7 | {
8 | public class DbContextTestsUsingConstructorParameters : BaseForDbContextTests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | MockedDbContext = Create.MockedDbContextFor(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/DbContextTestsUsingConstructorParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
7 | {
8 | public class DbContextTestsUsingConstructorParameters : BaseForDbContextTests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | MockedDbContext = Create.MockedDbContextFor(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/Issue126Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.Moq.Tests
7 | {
8 | public class Issue126Tests : Issue126Tests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | var options = new DbContextOptionsBuilder()
16 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
17 | .Options;
18 |
19 | DbContextFactory = () => Create.MockedDbContextFor(options);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/Issue88Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.Moq.Tests
7 | {
8 | public class Issue88Tests : Issue88Tests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | var options = new DbContextOptionsBuilder()
16 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
17 | .Options;
18 |
19 | DbContextFactory = () => Create.MockedDbContextFor(options);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/Issue126Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
7 | {
8 | public class Issue126Tests : Issue126Tests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | var options = new DbContextOptionsBuilder()
16 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
17 | .Options;
18 |
19 | DbContextFactory = () => Create.MockedDbContextFor(options);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/ByTypeReadOnlyDbSetExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using Microsoft.EntityFrameworkCore;
3 | using NUnit.Framework;
4 |
5 | namespace EntityFrameworkCore.Testing.Moq.Tests
6 | {
7 | public class ByTypeReadOnlyDbSetExceptionTests : ReadOnlyDbSetExceptionTests
8 | {
9 | protected TestDbContext MockedDbContext;
10 |
11 | protected override DbSet DbSet => MockedDbContext.Set();
12 |
13 | [SetUp]
14 | public override void SetUp()
15 | {
16 | base.SetUp();
17 |
18 | MockedDbContext = Create.MockedDbContextFor();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq.Tests/ByPropertyReadOnlyDbSetExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using Microsoft.EntityFrameworkCore;
3 | using NUnit.Framework;
4 |
5 | namespace EntityFrameworkCore.Testing.Moq.Tests
6 | {
7 | public class ByPropertyReadOnlyDbSetExceptionTests : ReadOnlyDbSetExceptionTests
8 | {
9 | protected TestDbContext MockedDbContext;
10 |
11 | protected override DbSet DbSet => MockedDbContext.TestReadOnlyEntities;
12 |
13 | [SetUp]
14 | public override void SetUp()
15 | {
16 | base.SetUp();
17 |
18 | MockedDbContext = Create.MockedDbContextFor();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/Issue88Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
7 | {
8 | public class Issue88Tests : Issue88Tests
9 | {
10 | [SetUp]
11 | public override void SetUp()
12 | {
13 | base.SetUp();
14 |
15 | var options = new DbContextOptionsBuilder()
16 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
17 | .Options;
18 |
19 | DbContextFactory = () => Create.MockedDbContextFor(options);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByTypeReadOnlyDbSetExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using Microsoft.EntityFrameworkCore;
3 | using NUnit.Framework;
4 |
5 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
6 | {
7 | public class ByTypeReadOnlyDbSetExceptionTests : ReadOnlyDbSetExceptionTests
8 | {
9 | protected TestDbContext MockedDbContext;
10 |
11 | protected override DbSet DbSet => MockedDbContext.Set();
12 |
13 | [SetUp]
14 | public override void SetUp()
15 | {
16 | base.SetUp();
17 |
18 | MockedDbContext = Create.MockedDbContextFor();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByPropertyReadOnlyDbSetExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Tests;
2 | using Microsoft.EntityFrameworkCore;
3 | using NUnit.Framework;
4 |
5 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
6 | {
7 | public class ByPropertyReadOnlyDbSetExceptionTests : ReadOnlyDbSetExceptionTests
8 | {
9 | protected TestDbContext MockedDbContext;
10 |
11 | protected override DbSet DbSet => MockedDbContext.TestReadOnlyEntities;
12 |
13 | [SetUp]
14 | public override void SetUp()
15 | {
16 | base.SetUp();
17 |
18 | MockedDbContext = Create.MockedDbContextFor();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/BaseForTests.cs:
--------------------------------------------------------------------------------
1 | using AutoFixture;
2 | using Microsoft.Extensions.Logging;
3 | using NUnit.Framework;
4 | using rgvlee.Core.Common.Helpers;
5 |
6 | namespace EntityFrameworkCore.Testing.Common.Tests
7 | {
8 | public abstract class BaseForTests
9 | {
10 | protected Fixture Fixture;
11 |
12 | [SetUp]
13 | public virtual void SetUp()
14 | {
15 | LoggingHelper.LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Trace));
16 |
17 | Fixture = new Fixture();
18 | }
19 |
20 | [TearDown]
21 | public virtual void TearDown()
22 | {
23 | LoggingHelper.LoggerFactory.Dispose();
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common/AsyncEnumerator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 |
4 | namespace EntityFrameworkCore.Testing.Common
5 | {
6 | public class AsyncEnumerator : IAsyncEnumerator
7 | {
8 | private readonly IEnumerator _enumerator;
9 |
10 | public AsyncEnumerator(IEnumerable enumerable)
11 | {
12 | _enumerator = enumerable.GetEnumerator();
13 | }
14 |
15 | public ValueTask DisposeAsync()
16 | {
17 | return new();
18 | }
19 |
20 | public ValueTask MoveNextAsync()
21 | {
22 | return new(_enumerator.MoveNext());
23 | }
24 |
25 | public T Current => _enumerator.Current;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq/Helpers/MockedDbContextBuilder.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Helpers;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace EntityFrameworkCore.Testing.Moq.Helpers
5 | {
6 | ///
7 | /// The mocked db context builder.
8 | ///
9 | /// The db context type.
10 | public class MockedDbContextBuilder : BaseMockedDbContextBuilder where TDbContext : DbContext
11 | {
12 | ///
13 | /// Creates the mocked db context.
14 | ///
15 | /// A mocked db context.
16 | public override TDbContext MockedDbContext => new MockedDbContextFactory(Options).Create();
17 | }
18 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute/Helpers/MockedDbContextBuilder.cs:
--------------------------------------------------------------------------------
1 | using EntityFrameworkCore.Testing.Common.Helpers;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace EntityFrameworkCore.Testing.NSubstitute.Helpers
5 | {
6 | ///
7 | /// The mocked db context builder.
8 | ///
9 | /// The db context type.
10 | public class MockedDbContextBuilder : BaseMockedDbContextBuilder where TDbContext : DbContext
11 | {
12 | ///
13 | /// Creates the mocked db context.
14 | ///
15 | /// A mocked db context.
16 | public override TDbContext MockedDbContext => new MockedDbContextFactory(Options).Create();
17 | }
18 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.DefaultBehaviour.Tests/ByTypeReadOnlyDbSetExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using NUnit.Framework;
5 |
6 | namespace EntityFrameworkCore.DefaultBehaviour.Tests
7 | {
8 | public class ReadOnlyDbSetExceptionTests : ReadOnlyDbSetExceptionTests
9 | {
10 | protected TestDbContext DbContext;
11 |
12 | protected override DbSet DbSet => DbContext.Set();
13 |
14 | [SetUp]
15 | public override void SetUp()
16 | {
17 | base.SetUp();
18 |
19 | DbContext = new TestDbContext(new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.DefaultBehaviour.Tests/Issue88Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EntityFrameworkCore.Testing.Common.Tests;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Diagnostics;
5 | using NUnit.Framework;
6 |
7 | namespace EntityFrameworkCore.DefaultBehaviour.Tests
8 | {
9 | public class Issue88Tests : Issue88Tests
10 | {
11 | [SetUp]
12 | public override void SetUp()
13 | {
14 | base.SetUp();
15 |
16 | var options = new DbContextOptionsBuilder()
17 | .UseInMemoryDatabase(Guid.NewGuid().ToString())
18 | .ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
19 | .Options;
20 |
21 | DbContextFactory = () => new TestDbContext(options);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute.Tests/ByTypeDbSetTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Linq.Expressions;
3 | using EntityFrameworkCore.Testing.Common.Tests;
4 | using NSubstitute;
5 | using NUnit.Framework;
6 |
7 | namespace EntityFrameworkCore.Testing.NSubstitute.Tests
8 | {
9 | public class ByTypeDbSetTests : BaseForDbSetTests
10 | {
11 | protected override IQueryable Queryable => MockedDbContext.Set();
12 |
13 | [Test(Description = "This test ensures that method invoked via CallBase = true are verifiable")]
14 | public override void Select_ReturnsSequence()
15 | {
16 | base.Select_ReturnsSequence();
17 |
18 | Queryable.Provider.Received(2).CreateQuery(Arg.Any());
19 |
20 | Queryable.Provider.Received(2).CreateQuery(Arg.Is(mce => mce.Method.Name.Equals(nameof(System.Linq.Queryable.Select))));
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Moq/EntityFrameworkCore.Testing.Moq.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | rgvlee
6 |
7 |
8 |
9 | EntityFrameworkCore.Testing.Moq.xml
10 | NU1605
11 |
12 |
13 |
14 | EntityFrameworkCore.Testing.Moq.xml
15 | true
16 | NU1605
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common.Tests/AsyncEnumerableTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using AutoFixture;
5 | using NUnit.Framework;
6 |
7 | namespace EntityFrameworkCore.Testing.Common.Tests
8 | {
9 | public class AsyncEnumerableTests : BaseForQueryableTests
10 | {
11 | private IQueryable _source;
12 |
13 | protected override IQueryable Queryable => _source;
14 |
15 | [SetUp]
16 | public override void SetUp()
17 | {
18 | base.SetUp();
19 |
20 | _source = new AsyncEnumerable(new List());
21 | }
22 |
23 | protected override void SeedQueryableSource()
24 | {
25 | var itemsToAdd = Fixture.Build().With(p => p.CreatedAt, DateTime.Today).With(p => p.LastModifiedAt, DateTime.Today).CreateMany().ToList();
26 | _source = new AsyncEnumerable(itemsToAdd);
27 | ItemsAddedToQueryableSource = itemsToAdd;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.NSubstitute/EntityFrameworkCore.Testing.NSubstitute.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | rgvlee
6 |
7 |
8 |
9 | EntityFrameworkCore.Testing.NSubstitute.xml
10 | NU1605
11 |
12 |
13 |
14 | EntityFrameworkCore.Testing.NSubstitute.xml
15 | true
16 | NU1605
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/EntityFrameworkCore.Testing.Common/Helpers/MockedDbContextFactoryOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace EntityFrameworkCore.Testing.Common.Helpers
5 | {
6 | ///
7 | /// The mocked db context factory options.
8 | ///
9 | /// The db context type.
10 | public class MockedDbContextFactoryOptions where TDbContext : DbContext
11 | {
12 | ///
13 | /// The db context instance that the mocked db context will use for in-memory provider supported operations.
14 | ///
15 | public TDbContext DbContext { get; set; }
16 |
17 | ///
18 | /// The parameters that will be used to create the mocked db context and, if one is not provided,
19 | /// the in-memory context that the mocked db context will use for in-memory provider supported operations.
20 | ///
21 | public IEnumerable