Skip to content

Commit c3c4637

Browse files
committed
#283 Separating With and Without Entities from InMemoryDB context builders.
1 parent 46f4508 commit c3c4637

14 files changed

+400
-348
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/// <summary>
44
/// Used for adding AndAlso() method to the <see cref="Microsoft.EntityFrameworkCore.DbContext"/> builder.
55
/// </summary>
6-
public interface IAndDbContextBuilder : IDbContextBuilder
6+
public interface IAndWithDbContextBuilder : IWithDbContextBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when building <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.
1010
/// </summary>
11-
/// <returns>The same <see cref="IDbContextBuilder"/>.</returns>
12-
IDbContextBuilder AndAlso();
11+
/// <returns>The same <see cref="IWithDbContextBuilder"/>.</returns>
12+
IWithDbContextBuilder AndAlso();
1313
}
1414
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/// <summary>
44
/// Used for adding AndAlso() method to the <see cref="Microsoft.EntityFrameworkCore.DbContext"/> test builder.
55
/// </summary>
6-
public interface IAndDbContextTestBuilder : IDbContextTestBuilder
6+
public interface IAndWithDbContextTestBuilder : IWithDbContextTestBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when testing <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.
1010
/// </summary>
11-
/// <returns>The same <see cref="IDbContextTestBuilder"/>.</returns>
12-
IDbContextTestBuilder AndAlso();
11+
/// <returns>The same <see cref="IWithDbContextTestBuilder"/>.</returns>
12+
IWithDbContextTestBuilder AndAlso();
1313
}
1414
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
2+
{
3+
/// <summary>
4+
/// Used for adding AndAlso() method to the <see cref="Microsoft.EntityFrameworkCore.DbContext"/> builder.
5+
/// </summary>
6+
public interface IAndWithoutDbContextBuilder : IWithoutDbContextBuilder
7+
{
8+
/// <summary>
9+
/// AndAlso method for better readability when building <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.
10+
/// </summary>
11+
/// <returns>The same <see cref="IWithDbContextBuilder"/>.</returns>
12+
IWithoutDbContextBuilder AndAlso();
13+
}
14+
}

src/MyTested.AspNetCore.Mvc.EntityFrameworkCore/Builders/Contracts/Data/IDbContextBuilder.cs

Lines changed: 0 additions & 154 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Microsoft.EntityFrameworkCore;
6+
7+
/// <summary>
8+
/// Used for building <see cref="DbContext"/>.
9+
/// </summary>
10+
public interface IWithDbContextBuilder
11+
{
12+
/// <summary>
13+
/// Sets initial values to the registered <see cref="DbContext"/>.
14+
/// </summary>
15+
/// <param name="entities">Initial values to add to the registered <see cref="DbContext"/>.</param>
16+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
17+
IAndWithDbContextBuilder WithEntities(IEnumerable<object> entities);
18+
19+
/// <summary>
20+
/// Sets initial values to the provided <see cref="DbContext"/>.
21+
/// </summary>
22+
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/> to set up.</typeparam>
23+
/// <param name="entities">Initial values to add to the provided <see cref="DbContext"/>.</param>
24+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
25+
IAndWithDbContextBuilder WithEntities<TDbContext>(IEnumerable<object> entities)
26+
where TDbContext : DbContext;
27+
28+
/// <summary>
29+
/// Sets initial values to the registered <see cref="DbContext"/>.
30+
/// </summary>
31+
/// <param name="entities">Initial values to add to the registered <see cref="DbContext"/>.</param>
32+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
33+
IAndWithDbContextBuilder WithEntities(params object[] entities);
34+
35+
/// <summary>
36+
/// Sets initial values to the provided <see cref="DbContext"/>.
37+
/// </summary>
38+
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/> to set up.</typeparam>
39+
/// <param name="entities">Initial values to add to the provided <see cref="DbContext"/>.</param>
40+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
41+
IAndWithDbContextBuilder WithEntities<TDbContext>(params object[] entities)
42+
where TDbContext : DbContext;
43+
44+
/// <summary>
45+
/// Sets initial values to the registered <see cref="DbContext"/>.
46+
/// </summary>
47+
/// <param name="dbContextSetup">Action setting the <see cref="DbContext"/>.</param>
48+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
49+
IAndWithDbContextBuilder WithEntities(Action<DbContext> dbContextSetup);
50+
51+
/// <summary>
52+
/// Sets initial values to the provided <see cref="DbContext"/>.
53+
/// </summary>
54+
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/> to set up.</typeparam>
55+
/// <param name="dbContextSetup">Action setting the <see cref="DbContext"/>.</param>
56+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
57+
IAndWithDbContextBuilder WithEntities<TDbContext>(Action<TDbContext> dbContextSetup)
58+
where TDbContext : DbContext;
59+
60+
/// <summary>
61+
/// Sets initial values to the provided <see cref="DbContext"/> entity.
62+
/// </summary>
63+
/// <typeparam name="TEntity">Type of entity to set up.</typeparam>
64+
/// <param name="entitySetup">Action setting the <see cref="DbContext"/> entity.</param>
65+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
66+
IAndWithDbContextBuilder WithSet<TEntity>(Action<DbSet<TEntity>> entitySetup)
67+
where TEntity : class;
68+
69+
/// <summary>
70+
/// Sets initial values to the provided <see cref="DbContext"/> entity.
71+
/// </summary>
72+
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/> to set up.</typeparam>
73+
/// <typeparam name="TEntity">Type of entity to set up.</typeparam>
74+
/// <param name="entitySetup">Action setting the <see cref="DbContext"/> entity.</param>
75+
/// <returns>The same <see cref="DbContext"/> builder.</returns>
76+
IAndWithDbContextBuilder WithSet<TDbContext, TEntity>(Action<DbSet<TEntity>> entitySetup)
77+
where TDbContext : DbContext
78+
where TEntity : class;
79+
}
80+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,52 @@
66
/// <summary>
77
/// Used for testing <see cref="DbContext"/>.
88
/// </summary>
9-
public interface IDbContextTestBuilder
9+
public interface IWithDbContextTestBuilder
1010
{
1111
/// <summary>
1212
/// Tests whether <see cref="DbContext"/> entities pass the given assertions.
1313
/// </summary>
1414
/// <param name="assertions">Action containing all assertions for the <see cref="DbContext"/> entities.</param>
15-
/// <returns>The same <see cref="IDbContextTestBuilder"/>.</returns>
16-
IAndDbContextTestBuilder WithEntities(Action<DbContext> assertions);
15+
/// <returns>The same <see cref="IWithDbContextTestBuilder"/>.</returns>
16+
IAndWithDbContextTestBuilder WithEntities(Action<DbContext> assertions);
1717

1818
/// <summary>
1919
/// Tests whether <see cref="DbContext"/> entities pass the given predicate.
2020
/// </summary>
2121
/// <param name="predicate">Predicate testing the <see cref="DbContext"/> entities.</param>
22-
/// <returns>The same <see cref="IDbContextTestBuilder"/>.</returns>
23-
IAndDbContextTestBuilder WithEntities(Func<DbContext, bool> predicate);
22+
/// <returns>The same <see cref="IWithDbContextTestBuilder"/>.</returns>
23+
IAndWithDbContextTestBuilder WithEntities(Func<DbContext, bool> predicate);
2424

2525
/// <summary>
2626
/// Tests whether <see cref="DbContext"/> entities pass the given assertions.
2727
/// </summary>
2828
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/>.</typeparam>
2929
/// <param name="assertions">Action containing all assertions for the <see cref="DbContext"/> entities.</param>
30-
IAndDbContextTestBuilder WithEntities<TDbContext>(Action<TDbContext> assertions)
30+
IAndWithDbContextTestBuilder WithEntities<TDbContext>(Action<TDbContext> assertions)
3131
where TDbContext : DbContext;
3232

3333
/// <summary>
3434
/// Tests whether <see cref="DbContext"/> entities pass the given predicate.
3535
/// </summary>
3636
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/>.</typeparam>
3737
/// <param name="predicate">Predicate testing the <see cref="DbContext"/> entities.</param>
38-
IAndDbContextTestBuilder WithEntities<TDbContext>(Func<TDbContext, bool> predicate)
38+
IAndWithDbContextTestBuilder WithEntities<TDbContext>(Func<TDbContext, bool> predicate)
3939
where TDbContext : DbContext;
4040

4141
/// <summary>
4242
/// Tests whether <see cref="DbContext"/> entity <see cref="DbSet{TEntity}"/> passes the given assertions.
4343
/// </summary>
4444
/// <typeparam name="TEntity">Type of entity set.</typeparam>
4545
/// <param name="assertions">Action containing all assertions for the <see cref="DbContext"/> entity set.</param>
46-
IAndDbContextTestBuilder WithSet<TEntity>(Action<DbSet<TEntity>> assertions)
46+
IAndWithDbContextTestBuilder WithSet<TEntity>(Action<DbSet<TEntity>> assertions)
4747
where TEntity : class;
4848

4949
/// <summary>
5050
/// Tests whether <see cref="DbContext"/> entity <see cref="DbSet{TEntity}"/> passes the given predicate.
5151
/// </summary>
5252
/// <typeparam name="TEntity">Type of entity set.</typeparam>
5353
/// <param name="predicate">Predicate testing the <see cref="DbContext"/> entity set.</param>
54-
IAndDbContextTestBuilder WithSet<TEntity>(Func<DbSet<TEntity>, bool> predicate)
54+
IAndWithDbContextTestBuilder WithSet<TEntity>(Func<DbSet<TEntity>, bool> predicate)
5555
where TEntity : class;
5656

5757
/// <summary>
@@ -60,7 +60,7 @@ IAndDbContextTestBuilder WithSet<TEntity>(Func<DbSet<TEntity>, bool> predicate)
6060
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/>.</typeparam>
6161
/// <typeparam name="TEntity">Type of entity set.</typeparam>
6262
/// <param name="assertions">Action containing all assertions for the <see cref="DbContext"/> entity set.</param>
63-
IAndDbContextTestBuilder WithSet<TDbContext, TEntity>(Action<DbSet<TEntity>> assertions)
63+
IAndWithDbContextTestBuilder WithSet<TDbContext, TEntity>(Action<DbSet<TEntity>> assertions)
6464
where TDbContext : DbContext
6565
where TEntity : class;
6666

@@ -70,7 +70,7 @@ IAndDbContextTestBuilder WithSet<TDbContext, TEntity>(Action<DbSet<TEntity>> ass
7070
/// <typeparam name="TDbContext">Type of <see cref="DbContext"/>.</typeparam>
7171
/// <typeparam name="TEntity">Type of entity set.</typeparam>
7272
/// <param name="predicate">Predicate testing the <see cref="DbContext"/> entity set.</param>
73-
IAndDbContextTestBuilder WithSet<TDbContext, TEntity>(Func<DbSet<TEntity>, bool> predicate)
73+
IAndWithDbContextTestBuilder WithSet<TDbContext, TEntity>(Func<DbSet<TEntity>, bool> predicate)
7474
where TDbContext : DbContext
7575
where TEntity : class;
7676
}

0 commit comments

Comments
 (0)