Skip to content

Commit 24a4e68

Browse files
committed
chore: remove FluentAssertions
1 parent 836eb9d commit 24a4e68

File tree

34 files changed

+161
-192
lines changed

34 files changed

+161
-192
lines changed

src/Cnblogs.Architecture.Ddd.Cqrs.Abstractions/CommandResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public record CommandResponse : IValidationResponse, ILockableResponse
2626
public string ErrorMessage { get; init; } = string.Empty;
2727

2828
/// <inheritdoc />
29-
public ValidationErrors ValidationErrors { get; init; } = new();
29+
public ValidationErrors ValidationErrors { get; init; } = [];
3030

3131
/// <inheritdoc />
3232
public bool LockAcquired { get; set; }

src/Cnblogs.Architecture.Ddd.Cqrs.Abstractions/ValidationErrors.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Cnblogs.Architecture.Ddd.Cqrs.Abstractions;
77
/// </summary>
88
public class ValidationErrors : ICollection<ValidationError>
99
{
10-
private readonly List<ValidationError> _validationErrors = new();
10+
private readonly List<ValidationError> _validationErrors = [];
1111

1212
/// <summary>
1313
/// Add a new validation error.

src/Cnblogs.Architecture.Ddd.Cqrs.AspNetCore/CqrsRouteMapper.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@ namespace Cnblogs.Architecture.Ddd.Cqrs.AspNetCore;
1515
/// </summary>
1616
public static class CqrsRouteMapper
1717
{
18-
private static readonly List<Type> QueryTypes = new() { typeof(IQuery<>), typeof(IListQuery<>) };
18+
private static readonly List<Type> QueryTypes = [typeof(IQuery<>), typeof(IListQuery<>)];
1919

20-
private static readonly List<Type> CommandTypes = new() { typeof(ICommand<>), typeof(ICommand<,>) };
20+
private static readonly List<Type> CommandTypes = [typeof(ICommand<>), typeof(ICommand<,>)];
2121

22-
private static readonly string[] GetAndHeadMethods = { "GET", "HEAD" };
22+
private static readonly string[] GetAndHeadMethods = ["GET", "HEAD"];
2323

24-
private static readonly List<string> PostCommandPrefixes = new()
25-
{
24+
private static readonly List<string> PostCommandPrefixes =
25+
[
2626
"Create",
2727
"Add",
2828
"New"
29-
};
29+
];
3030

31-
private static readonly List<string> PutCommandPrefixes = new()
32-
{
31+
private static readonly List<string> PutCommandPrefixes =
32+
[
3333
"Update",
3434
"Modify",
3535
"Replace",
3636
"Alter"
37-
};
37+
];
3838

39-
private static readonly List<string> DeleteCommandPrefixes = new()
40-
{
39+
private static readonly List<string> DeleteCommandPrefixes =
40+
[
4141
"Delete",
4242
"Remove",
4343
"Clean",
4444
"Clear",
4545
"Purge"
46-
};
46+
];
4747

4848
/// <summary>
4949
/// Map a query API, using GET method. <typeparamref name="T"/> would been constructed from route and query string.

src/Cnblogs.Architecture.Ddd.Cqrs.Dapper.Clickhouse/ClickhouseContextCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Cnblogs.Architecture.Ddd.Cqrs.Dapper.Clickhouse;
55
/// </summary>
66
public class ClickhouseContextCollection
77
{
8-
internal List<Type> ContextTypes { get; } = new();
8+
internal List<Type> ContextTypes { get; } = [];
99

1010
internal void Add<TContext>()
1111
{

src/Cnblogs.Architecture.Ddd.Cqrs.MongoDb/MongoContextCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Cnblogs.Architecture.Ddd.Cqrs.MongoDb;
77
/// </summary>
88
public class MongoContextCollection
99
{
10-
private readonly List<Type> _contexts = new();
10+
private readonly List<Type> _contexts = [];
1111

1212
/// <summary>
1313
/// 添加一个 MongoContext。

src/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent/CqrsServiceAgent.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public async Task<CommandResponse<TResponse, TError>> PutCommandAsync<TResponse,
155155
return response.StatusCode switch
156156
{
157157
HttpStatusCode.OK => await response.Content.ReadFromJsonAsync<T>(),
158-
HttpStatusCode.NotFound => default,
159158
_ => default
160159
};
161160
}
@@ -202,7 +201,7 @@ public async Task<List<TResponse>> BatchGetItemsAsync<TResponse, TId>(
202201
'&',
203202
ids.Select(i => $"{WebUtility.UrlEncode(paramName)}={WebUtility.UrlEncode(i.ToString())}"));
204203
url = $"{url}{(url.Contains('?') ? '&' : '?')}{query}";
205-
return await HttpClient.GetFromJsonAsync<List<TResponse>>(url) ?? new List<TResponse>();
204+
return await HttpClient.GetFromJsonAsync<List<TResponse>>(url) ?? [];
206205
}
207206

208207
/// <summary>

src/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent/ServiceAgentBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public async Task<List<TResponse>> BatchGetItemsAsync<TResponse, TId>(
293293
'&',
294294
ids.Select(i => $"{WebUtility.UrlEncode(paramName)}={WebUtility.UrlEncode(i.ToString())}"));
295295
url = $"{url}{(url.Contains('?') ? '&' : '?')}{query}";
296-
return await HttpClient.GetFromJsonAsync<List<TResponse>>(url) ?? new List<TResponse>();
296+
return await HttpClient.GetFromJsonAsync<List<TResponse>>(url) ?? [];
297297
}
298298
catch (HttpRequestException e)
299299
{
@@ -306,7 +306,7 @@ public async Task<List<TResponse>> BatchGetItemsAsync<TResponse, TId>(
306306
ThrowApiException(HttpMethod.Get, url, e);
307307
}
308308

309-
return new List<TResponse>();
309+
return [];
310310
}
311311
}
312312

src/Cnblogs.Architecture.Ddd.Domain.Abstractions/Entity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class Entity<TKey> : Entity, IEntity<TKey>
4949
/// <param name="generator">领域事件生成器。</param>
5050
public void AddDomainEvent(Func<TKey, IDomainEvent> generator)
5151
{
52-
_domainEventGenerator ??= new List<Func<TKey, IDomainEvent>>();
52+
_domainEventGenerator ??= [];
5353
_domainEventGenerator.Add(generator);
5454
}
5555

src/Cnblogs.Architecture.Ddd.Domain.Abstractions/EntityBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class EntityBase : IDomainEventSource
1818
/// <param name="eventItem">领域事件。</param>
1919
public virtual void AddDomainEvent(IDomainEvent eventItem)
2020
{
21-
_events ??= new List<IDomainEvent>();
21+
_events ??= [];
2222
_events.Add(eventItem);
2323
}
2424

src/Cnblogs.Architecture.Ddd.EventBus.Dapr/EndPointExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ private static MethodInfo GetSubscribeMethod()
182182
{
183183
return typeof(EndPointExtensions).GetMethod(
184184
nameof(Subscribe),
185-
new[] { typeof(IEndpointRouteBuilder), typeof(string) })!;
185+
[typeof(IEndpointRouteBuilder), typeof(string)])!;
186186
}
187187

188188
private static void InvokeSubscribe(this MethodInfo method, Type eventType, IEndpointRouteBuilder builder, string appName)
189189
{
190-
method.MakeGenericMethod(eventType).Invoke(null, new object[] { builder, appName });
190+
method.MakeGenericMethod(eventType).Invoke(null, [builder, appName]);
191191
}
192192

193193
private static string GetAppName(this Assembly assembly)

0 commit comments

Comments
 (0)