Skip to content

Commit 7bb071c

Browse files
committed
#283 Changing the interfaces and builders name to be consistent with the functionallity for With And WithoutUser.
1 parent cc39821 commit 7bb071c

12 files changed

Lines changed: 120 additions & 107 deletions

File tree

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Authentication/ClaimsIdentityBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Authentication/WithClaimsIdentityBuilder.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,85 @@
88
/// <summary>
99
/// Used for creating mocked authenticated <see cref="ClaimsIdentity"/>.
1010
/// </summary>
11-
public class ClaimsIdentityBuilder : BaseUserBuilder, IAndClaimsIdentityBuilder
11+
public class WithClaimsIdentityBuilder : BaseUserBuilder, IAndWithClaimsIdentityBuilder
1212
{
1313
/// <inheritdoc />
14-
public IAndClaimsIdentityBuilder WithNameType(string nameType)
14+
public IAndWithClaimsIdentityBuilder WithNameType(string nameType)
1515
{
1616
this.AddNameType(nameType);
1717
return this;
1818
}
1919

2020
/// <inheritdoc />
21-
public IAndClaimsIdentityBuilder WithRoleType(string roleType)
21+
public IAndWithClaimsIdentityBuilder WithRoleType(string roleType)
2222
{
2323
this.AddRoleType(roleType);
2424
return this;
2525
}
2626

2727
/// <inheritdoc />
28-
public IAndClaimsIdentityBuilder WithIdentifier(string identifier)
28+
public IAndWithClaimsIdentityBuilder WithIdentifier(string identifier)
2929
{
3030
this.AddIdentifier(identifier);
3131
return this;
3232
}
3333

3434
/// <inheritdoc />
35-
public IAndClaimsIdentityBuilder WithUsername(string username)
35+
public IAndWithClaimsIdentityBuilder WithUsername(string username)
3636
{
3737
this.AddUsername(username);
3838
return this;
3939
}
4040

4141
/// <inheritdoc />
42-
public IAndClaimsIdentityBuilder WithClaim(string type, string value)
42+
public IAndWithClaimsIdentityBuilder WithClaim(string type, string value)
4343
=> this.WithClaim(new Claim(type, value));
4444

4545
/// <inheritdoc />
46-
public IAndClaimsIdentityBuilder WithClaim(Claim claim)
46+
public IAndWithClaimsIdentityBuilder WithClaim(Claim claim)
4747
{
4848
this.AddClaim(claim);
4949
return this;
5050
}
5151

5252
/// <inheritdoc />
53-
public IAndClaimsIdentityBuilder WithClaims(IEnumerable<Claim> claims)
53+
public IAndWithClaimsIdentityBuilder WithClaims(IEnumerable<Claim> claims)
5454
{
5555
this.AddClaims(claims);
5656
return this;
5757
}
5858

5959
/// <inheritdoc />
60-
public IAndClaimsIdentityBuilder WithClaims(params Claim[] claims)
60+
public IAndWithClaimsIdentityBuilder WithClaims(params Claim[] claims)
6161
=> this.WithClaims(claims.AsEnumerable());
6262

6363
/// <inheritdoc />
64-
public IAndClaimsIdentityBuilder WithAuthenticationType(string authenticationType)
64+
public IAndWithClaimsIdentityBuilder WithAuthenticationType(string authenticationType)
6565
{
6666
this.AddAuthenticationType(authenticationType);
6767
return this;
6868
}
6969

7070
/// <inheritdoc />
71-
public IAndClaimsIdentityBuilder InRole(string role)
71+
public IAndWithClaimsIdentityBuilder InRole(string role)
7272
{
7373
this.AddRole(role);
7474
return this;
7575
}
7676

7777
/// <inheritdoc />
78-
public IAndClaimsIdentityBuilder InRoles(IEnumerable<string> roles)
78+
public IAndWithClaimsIdentityBuilder InRoles(IEnumerable<string> roles)
7979
{
8080
this.AddRoles(roles);
8181
return this;
8282
}
8383

8484
/// <inheritdoc />
85-
public IAndClaimsIdentityBuilder InRoles(params string[] roles)
85+
public IAndWithClaimsIdentityBuilder InRoles(params string[] roles)
8686
=> this.InRoles(roles.AsEnumerable());
8787

8888
/// <inheritdoc />
89-
public IClaimsIdentityBuilder AndAlso() => this;
89+
public IWithClaimsIdentityBuilder AndAlso() => this;
9090

9191
internal ClaimsIdentity GetClaimsIdentity()
9292
=> this.GetAuthenticatedClaimsIdentity();

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Authentication/ClaimsPrincipalBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Authentication/WithClaimsPrincipalBuilder.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
/// <summary>
1111
/// Used for building mocked <see cref="ClaimsPrincipal"/>.
1212
/// </summary>
13-
public class ClaimsPrincipalBuilder : BaseUserBuilder, IAndClaimsPrincipalBuilder
13+
public class WithClaimsPrincipalBuilder : BaseUserBuilder, IAndWithClaimsPrincipalBuilder
1414
{
1515
private readonly ICollection<ClaimsIdentity> identities;
1616

1717
/// <summary>
18-
/// Initializes a new instance of the <see cref="ClaimsPrincipalBuilder"/> class.
18+
/// Initializes a new instance of the <see cref="WithClaimsPrincipalBuilder"/> class.
1919
/// </summary>
20-
public ClaimsPrincipalBuilder()
20+
public WithClaimsPrincipalBuilder()
2121
=> this.identities = new List<ClaimsIdentity>();
2222

2323
/// <summary>
@@ -29,82 +29,82 @@ public ClaimsPrincipalBuilder()
2929
= new ClaimsPrincipal(CreateAuthenticatedClaimsIdentity());
3030

3131
/// <inheritdoc />
32-
public IAndClaimsPrincipalBuilder WithNameType(string nameType)
32+
public IAndWithClaimsPrincipalBuilder WithNameType(string nameType)
3333
{
3434
this.AddNameType(nameType);
3535
return this;
3636
}
3737

3838
/// <inheritdoc />
39-
public IAndClaimsPrincipalBuilder WithRoleType(string roleType)
39+
public IAndWithClaimsPrincipalBuilder WithRoleType(string roleType)
4040
{
4141
this.AddRoleType(roleType);
4242
return this;
4343
}
4444

4545
/// <inheritdoc />
46-
public IAndClaimsPrincipalBuilder WithIdentifier(string identifier)
46+
public IAndWithClaimsPrincipalBuilder WithIdentifier(string identifier)
4747
{
4848
this.AddIdentifier(identifier);
4949
return this;
5050
}
5151

5252
/// <inheritdoc />
53-
public IAndClaimsPrincipalBuilder WithUsername(string username)
53+
public IAndWithClaimsPrincipalBuilder WithUsername(string username)
5454
{
5555
this.AddUsername(username);
5656
return this;
5757
}
5858

5959
/// <inheritdoc />
60-
public IAndClaimsPrincipalBuilder WithClaim(string type, string value)
60+
public IAndWithClaimsPrincipalBuilder WithClaim(string type, string value)
6161
=> this.WithClaim(new Claim(type, value));
6262

6363
/// <inheritdoc />
64-
public IAndClaimsPrincipalBuilder WithClaim(Claim claim)
64+
public IAndWithClaimsPrincipalBuilder WithClaim(Claim claim)
6565
{
6666
this.AddClaim(claim);
6767
return this;
6868
}
6969

7070
/// <inheritdoc />
71-
public IAndClaimsPrincipalBuilder WithClaims(IEnumerable<Claim> claims)
71+
public IAndWithClaimsPrincipalBuilder WithClaims(IEnumerable<Claim> claims)
7272
{
7373
this.AddClaims(claims);
7474
return this;
7575
}
7676

7777
/// <inheritdoc />
78-
public IAndClaimsPrincipalBuilder WithClaims(params Claim[] claims)
78+
public IAndWithClaimsPrincipalBuilder WithClaims(params Claim[] claims)
7979
=> this.WithClaims(claims.AsEnumerable());
8080

8181
/// <inheritdoc />
82-
public IAndClaimsPrincipalBuilder WithAuthenticationType(string authenticationType)
82+
public IAndWithClaimsPrincipalBuilder WithAuthenticationType(string authenticationType)
8383
{
8484
this.AddAuthenticationType(authenticationType);
8585
return this;
8686
}
8787

8888
/// <inheritdoc />
89-
public IAndClaimsPrincipalBuilder InRole(string role)
89+
public IAndWithClaimsPrincipalBuilder InRole(string role)
9090
{
9191
this.AddRole(role);
9292
return this;
9393
}
9494

9595
/// <inheritdoc />
96-
public IAndClaimsPrincipalBuilder InRoles(IEnumerable<string> roles)
96+
public IAndWithClaimsPrincipalBuilder InRoles(IEnumerable<string> roles)
9797
{
9898
this.AddRoles(roles);
9999
return this;
100100
}
101101

102102
/// <inheritdoc />
103-
public IAndClaimsPrincipalBuilder InRoles(params string[] roles)
103+
public IAndWithClaimsPrincipalBuilder InRoles(params string[] roles)
104104
=> this.InRoles(roles.AsEnumerable());
105105

106106
/// <inheritdoc />
107-
public IAndClaimsPrincipalBuilder WithIdentity(IIdentity identity)
107+
public IAndWithClaimsPrincipalBuilder WithIdentity(IIdentity identity)
108108
{
109109
if (!(identity is ClaimsIdentity claimsIdentity))
110110
{
@@ -116,16 +116,16 @@ public IAndClaimsPrincipalBuilder WithIdentity(IIdentity identity)
116116
}
117117

118118
/// <inheritdoc />
119-
public IAndClaimsPrincipalBuilder WithIdentity(Action<IClaimsIdentityBuilder> claimsIdentityBuilder)
119+
public IAndWithClaimsPrincipalBuilder WithIdentity(Action<IWithClaimsIdentityBuilder> claimsIdentityBuilder)
120120
{
121-
var newClaimsIdentityBuilder = new ClaimsIdentityBuilder();
121+
var newClaimsIdentityBuilder = new WithClaimsIdentityBuilder();
122122
claimsIdentityBuilder(newClaimsIdentityBuilder);
123123
this.identities.Add(newClaimsIdentityBuilder.GetClaimsIdentity());
124124
return this;
125125
}
126126

127127
/// <inheritdoc />
128-
public IClaimsPrincipalBuilder AndAlso() => this;
128+
public IWithClaimsPrincipalBuilder AndAlso() => this;
129129

130130
public ClaimsPrincipal GetClaimsPrincipal()
131131
{

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IAndClaimsIdentityBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IAndWithClaimsIdentityBuilder.cs

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="System.Security.Claims.ClaimsIdentity"/> builder.
55
/// </summary>
6-
public interface IAndClaimsIdentityBuilder : IClaimsIdentityBuilder
6+
public interface IAndWithClaimsIdentityBuilder : IWithClaimsIdentityBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when building mocked <see cref="System.Security.Claims.ClaimsIdentity"/>.
1010
/// </summary>
11-
/// <returns>The same <see cref="IClaimsIdentityBuilder"/>.</returns>
12-
IClaimsIdentityBuilder AndAlso();
11+
/// <returns>The same <see cref="IWithClaimsIdentityBuilder"/>.</returns>
12+
IWithClaimsIdentityBuilder AndAlso();
1313
}
1414
}

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IAndClaimsPrincipalBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IAndWithClaimsPrincipalBuilder.cs

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="System.Security.Claims.ClaimsPrincipal"/> builder.
55
/// </summary>
6-
public interface IAndClaimsPrincipalBuilder : IClaimsPrincipalBuilder
6+
public interface IAndWithClaimsPrincipalBuilder : IWithClaimsPrincipalBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when building <see cref="System.Security.Claims.ClaimsPrincipal"/>.
1010
/// </summary>
11-
/// <returns>The same <see cref="IClaimsPrincipalBuilder"/>.</returns>
12-
IClaimsPrincipalBuilder AndAlso();
11+
/// <returns>The same <see cref="IWithClaimsPrincipalBuilder"/>.</returns>
12+
IWithClaimsPrincipalBuilder AndAlso();
1313
}
1414
}

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IClaimsIdentityBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Authentication/IWithClaimsIdentityBuilder.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,91 @@
66
/// <summary>
77
/// Used for building mocked <see cref="ClaimsIdentity"/>.
88
/// </summary>
9-
public interface IClaimsIdentityBuilder
9+
public interface IWithClaimsIdentityBuilder
1010
{
1111
/// <summary>
1212
/// Sets type of the username claim. Default is <see cref="ClaimTypes.Name"/>.
1313
/// </summary>
1414
/// <param name="nameType">Type to set on the username claim.</param>
15-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
16-
IAndClaimsIdentityBuilder WithNameType(string nameType);
15+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
16+
IAndWithClaimsIdentityBuilder WithNameType(string nameType);
1717

1818
/// <summary>
1919
/// Sets type of the role claim. Default is <see cref="ClaimTypes.Role"/>.
2020
/// </summary>
2121
/// <param name="roleType">Type to set on the role claim.</param>
22-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
23-
IAndClaimsIdentityBuilder WithRoleType(string roleType);
22+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
23+
IAndWithClaimsIdentityBuilder WithRoleType(string roleType);
2424

2525
/// <summary>
2626
/// Sets identifier claim to the built <see cref="ClaimsIdentity"/>. If such is not provided, "TestId" is used by default.
2727
/// </summary>
2828
/// <param name="identifier">Value of the identifier claim - <see cref="ClaimTypes.NameIdentifier"/>.</param>
29-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
30-
IAndClaimsIdentityBuilder WithIdentifier(string identifier);
29+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
30+
IAndWithClaimsIdentityBuilder WithIdentifier(string identifier);
3131

3232
/// <summary>
3333
/// Sets username claims to the built <see cref="ClaimsIdentity"/>. If such is not provided, "TestUser" is used by default.
3434
/// </summary>
3535
/// <param name="username">Value of the username claim. Default claim type is <see cref="ClaimTypes.Name"/>.</param>
36-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
37-
IAndClaimsIdentityBuilder WithUsername(string username);
36+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
37+
IAndWithClaimsIdentityBuilder WithUsername(string username);
3838

3939
/// <summary>
4040
/// Adds claim to the built <see cref="ClaimsIdentity"/>.
4141
/// </summary>
4242
/// <param name="type">Type of the <see cref="Claim"/> to add.</param>
4343
/// <param name="value">Value of the <see cref="Claim"/> to add.</param>
44-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
45-
IAndClaimsIdentityBuilder WithClaim(string type, string value);
44+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
45+
IAndWithClaimsIdentityBuilder WithClaim(string type, string value);
4646

4747
/// <summary>
4848
/// Adds claim to the built <see cref="ClaimsIdentity"/>.
4949
/// </summary>
5050
/// <param name="claim">The <see cref="Claim"/> to add.</param>
51-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
52-
IAndClaimsIdentityBuilder WithClaim(Claim claim);
51+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
52+
IAndWithClaimsIdentityBuilder WithClaim(Claim claim);
5353

5454
/// <summary>
5555
/// Adds claims to the built <see cref="ClaimsIdentity"/>.
5656
/// </summary>
5757
/// <param name="claims">Collection of <see cref="Claim"/> to add.</param>
58-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
59-
IAndClaimsIdentityBuilder WithClaims(IEnumerable<Claim> claims);
58+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
59+
IAndWithClaimsIdentityBuilder WithClaims(IEnumerable<Claim> claims);
6060

6161
/// <summary>
6262
/// Adds claims to the built <see cref="ClaimsIdentity"/>.
6363
/// </summary>
6464
/// <param name="claims"><see cref="Claim"/> parameters to add.</param>
65-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
66-
IAndClaimsIdentityBuilder WithClaims(params Claim[] claims);
65+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
66+
IAndWithClaimsIdentityBuilder WithClaims(params Claim[] claims);
6767

6868
/// <summary>
6969
/// Adds authentication type to the built <see cref="ClaimsIdentity"/>. If such is not provided, "Passport" is used by default.
7070
/// </summary>
7171
/// <param name="authenticationType">Authentication type to add.</param>
72-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
73-
IAndClaimsIdentityBuilder WithAuthenticationType(string authenticationType);
72+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
73+
IAndWithClaimsIdentityBuilder WithAuthenticationType(string authenticationType);
7474

7575
/// <summary>
7676
/// Adds role to the built <see cref="ClaimsIdentity"/>.
7777
/// </summary>
7878
/// <param name="role">Value of the role claim. Default claim type is <see cref="ClaimTypes.Role"/>.</param>
79-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
80-
IAndClaimsIdentityBuilder InRole(string role);
79+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
80+
IAndWithClaimsIdentityBuilder InRole(string role);
8181

8282
/// <summary>
8383
/// Adds roles to the built <see cref="ClaimsIdentity"/>.
8484
/// </summary>
8585
/// <param name="roles">Collection of role names to add.</param>
86-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
87-
IAndClaimsIdentityBuilder InRoles(IEnumerable<string> roles);
86+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
87+
IAndWithClaimsIdentityBuilder InRoles(IEnumerable<string> roles);
8888

8989
/// <summary>
9090
/// Adds roles to the built <see cref="ClaimsIdentity"/>.
9191
/// </summary>
9292
/// <param name="roles">Role name parameters to add.</param>
93-
/// <returns>The same <see cref="IAndClaimsIdentityBuilder"/>.</returns>
94-
IAndClaimsIdentityBuilder InRoles(params string[] roles);
93+
/// <returns>The same <see cref="IAndWithClaimsIdentityBuilder"/>.</returns>
94+
IAndWithClaimsIdentityBuilder InRoles(params string[] roles);
9595
}
9696
}

0 commit comments

Comments
 (0)