Use simpler syntax for default
This commit is contained in:
parent
02c163246b
commit
b9f48faf99
@ -13,7 +13,7 @@ public static class LinqSelectExtensions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
returnedValue = new SelectTryResult<TSource, TResult>(element, default(TResult), ex);
|
returnedValue = new SelectTryResult<TSource, TResult>(element, default, ex);
|
||||||
}
|
}
|
||||||
yield return returnedValue;
|
yield return returnedValue;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public abstract class IdentifiedCommandHandler<T, R> : IRequestHandler<Identifie
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return default(R);
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public static class LinqSelectExtensions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
returnedValue = new SelectTryResult<TSource, TResult>(element, default(TResult), ex);
|
returnedValue = new SelectTryResult<TSource, TResult>(element, default, ex);
|
||||||
}
|
}
|
||||||
yield return returnedValue;
|
yield return returnedValue;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public abstract class Entity
|
|||||||
|
|
||||||
public bool IsTransient()
|
public bool IsTransient()
|
||||||
{
|
{
|
||||||
return this.Id == default(Int32);
|
return this.Id == default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
public interface IUnitOfWork : IDisposable
|
public interface IUnitOfWork : IDisposable
|
||||||
{
|
{
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||||
Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class OrderingContext : DbContext, IUnitOfWork
|
|||||||
modelBuilder.ApplyConfiguration(new BuyerEntityTypeConfiguration());
|
modelBuilder.ApplyConfiguration(new BuyerEntityTypeConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default(CancellationToken))
|
public async Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
// Dispatch Domain Events collection.
|
// Dispatch Domain Events collection.
|
||||||
// Choices:
|
// Choices:
|
||||||
@ -120,12 +120,12 @@ public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<Ordering
|
|||||||
{
|
{
|
||||||
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)
|
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return default(IAsyncEnumerable<TResponse>);
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAsyncEnumerable<object?> CreateStream(object request, CancellationToken cancellationToken = default)
|
public IAsyncEnumerable<object?> CreateStream(object request, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return default(IAsyncEnumerable<object?>);
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
|
public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
|
||||||
@ -140,7 +140,7 @@ public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<Ordering
|
|||||||
|
|
||||||
public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
|
public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return Task.FromResult<TResponse>(default(TResponse));
|
return Task.FromResult<TResponse>(default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<object> Send(object request, CancellationToken cancellationToken = default)
|
public Task<object> Send(object request, CancellationToken cancellationToken = default)
|
||||||
|
@ -23,7 +23,7 @@ public class IdentifiedCommandHandlerTest
|
|||||||
_requestManager.Setup(x => x.ExistAsync(It.IsAny<Guid>()))
|
_requestManager.Setup(x => x.ExistAsync(It.IsAny<Guid>()))
|
||||||
.Returns(Task.FromResult(false));
|
.Returns(Task.FromResult(false));
|
||||||
|
|
||||||
_mediator.Setup(x => x.Send(It.IsAny<IRequest<bool>>(), default(System.Threading.CancellationToken)))
|
_mediator.Setup(x => x.Send(It.IsAny<IRequest<bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -33,7 +33,7 @@ public class IdentifiedCommandHandlerTest
|
|||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.True(result);
|
Assert.True(result);
|
||||||
_mediator.Verify(x => x.Send(It.IsAny<IRequest<bool>>(), default(System.Threading.CancellationToken)), Times.Once());
|
_mediator.Verify(x => x.Send(It.IsAny<IRequest<bool>>(), default), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -46,17 +46,16 @@ public class IdentifiedCommandHandlerTest
|
|||||||
_requestManager.Setup(x => x.ExistAsync(It.IsAny<Guid>()))
|
_requestManager.Setup(x => x.ExistAsync(It.IsAny<Guid>()))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
_mediator.Setup(x => x.Send(It.IsAny<IRequest<bool>>(), default(System.Threading.CancellationToken)))
|
_mediator.Setup(x => x.Send(It.IsAny<IRequest<bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var handler = new CreateOrderIdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object);
|
var handler = new CreateOrderIdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object);
|
||||||
var cltToken = new System.Threading.CancellationToken();
|
var result = await handler.Handle(fakeOrderCmd, CancellationToken.None);
|
||||||
var result = await handler.Handle(fakeOrderCmd, cltToken);
|
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.False(result);
|
Assert.False(result);
|
||||||
_mediator.Verify(x => x.Send(It.IsAny<IRequest<bool>>(), default(System.Threading.CancellationToken)), Times.Never());
|
_mediator.Verify(x => x.Send(It.IsAny<IRequest<bool>>(), default), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
private CreateOrderCommand FakeOrderRequest(Dictionary<string, object> args = null)
|
private CreateOrderCommand FakeOrderRequest(Dictionary<string, object> args = null)
|
||||||
|
@ -31,7 +31,7 @@ public class NewOrderRequestHandlerTest
|
|||||||
_orderRepositoryMock.Setup(orderRepo => orderRepo.GetAsync(It.IsAny<int>()))
|
_orderRepositoryMock.Setup(orderRepo => orderRepo.GetAsync(It.IsAny<int>()))
|
||||||
.Returns(Task.FromResult<Order>(FakeOrder()));
|
.Returns(Task.FromResult<Order>(FakeOrder()));
|
||||||
|
|
||||||
_orderRepositoryMock.Setup(buyerRepo => buyerRepo.UnitOfWork.SaveChangesAsync(default(CancellationToken)))
|
_orderRepositoryMock.Setup(buyerRepo => buyerRepo.UnitOfWork.SaveChangesAsync(default))
|
||||||
.Returns(Task.FromResult(1));
|
.Returns(Task.FromResult(1));
|
||||||
|
|
||||||
_identityServiceMock.Setup(svc => svc.GetUserIdentity()).Returns(buyerId);
|
_identityServiceMock.Setup(svc => svc.GetUserIdentity()).Returns(buyerId);
|
||||||
|
@ -21,7 +21,7 @@ public class OrdersWebApiTest
|
|||||||
public async Task Cancel_order_with_requestId_success()
|
public async Task Cancel_order_with_requestId_success()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CancelOrderCommand, bool>>(), default(CancellationToken)))
|
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CancelOrderCommand, bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -37,7 +37,7 @@ public class OrdersWebApiTest
|
|||||||
public async Task Cancel_order_bad_request()
|
public async Task Cancel_order_bad_request()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CancelOrderCommand, bool>>(), default(CancellationToken)))
|
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CancelOrderCommand, bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -52,7 +52,7 @@ public class OrdersWebApiTest
|
|||||||
public async Task Ship_order_with_requestId_success()
|
public async Task Ship_order_with_requestId_success()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<ShipOrderCommand, bool>>(), default(System.Threading.CancellationToken)))
|
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<ShipOrderCommand, bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -68,7 +68,7 @@ public class OrdersWebApiTest
|
|||||||
public async Task Ship_order_bad_request()
|
public async Task Ship_order_bad_request()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CreateOrderCommand, bool>>(), default(System.Threading.CancellationToken)))
|
_mediatorMock.Setup(x => x.Send(It.IsAny<IdentifiedCommand<CreateOrderCommand, bool>>(), default))
|
||||||
.Returns(Task.FromResult(true));
|
.Returns(Task.FromResult(true));
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{
|
{
|
||||||
var value = session.GetString(key);
|
var value = session.GetString(key);
|
||||||
|
|
||||||
return value == null ? default(T) : JsonSerializer.Deserialize<T>(value, new JsonSerializerOptions
|
return value == null ? default : JsonSerializer.Deserialize<T>(value, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
PropertyNameCaseInsensitive = true
|
PropertyNameCaseInsensitive = true
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user