Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class ContractDomainServiceTests {
public ContractDomainServiceTests() {
this.AggregateService = new Mock<IAggregateService>();
this.EventStoreContext = new Mock<IEventStoreContext>();
this.DomainService = new ContractDomainService(this.AggregateService.Object, this.EventStoreContext.Object);
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.DomainService = new ContractDomainService(AggregateServiceResolver, this.EventStoreContext.Object);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class EstateDomainServiceTests {
public EstateDomainServiceTests() {
this.AggregateService= new Mock<IAggregateService>();
this.SecurityServiceClient = new Mock<ISecurityServiceClient>();
this.DomainService = new EstateDomainService(this.AggregateService.Object, this.SecurityServiceClient.Object);
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.DomainService = new EstateDomainService(AggregateServiceResolver, this.SecurityServiceClient.Object);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public FloatDomainServiceTests(){
Logger.Initialise(NullLogger.Instance);

this.AggregateService = new Mock<IAggregateService>();

this.FloatDomainService = new FloatDomainService(this.AggregateService.Object);
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.FloatDomainService = new FloatDomainService(AggregateServiceResolver);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public MerchantDomainServiceTests() {

Logger.Initialise(new NullLogger());



this.AggregateService = new Mock<IAggregateService>();
this.SecurityServiceClient = new Mock<ISecurityServiceClient>();
this.EventStoreContext = new Mock<IEventStoreContext>();
this.DomainService = new MerchantDomainService(this.AggregateService.Object,
Func<IAggregateService> aggregateServiceResolver = () => this.AggregateService.Object;
this.DomainService = new MerchantDomainService(aggregateServiceResolver,
this.SecurityServiceClient.Object, this.EventStoreContext.Object);
}

Expand Down Expand Up @@ -425,11 +428,8 @@ public async Task MerchantDomainService_MakeMerchantDeposit_DepositIsMade()
this.AggregateService.Setup(e => e.Get<EstateAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate());

this.AggregateService.Setup(m => m.GetLatest<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
this.AggregateService.Setup(m => m.Get<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate()));
this.AggregateService
.Setup(m => m.Save(It.IsAny<MerchantAggregate>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success);

this.AggregateService
.Setup(m => m.GetLatest<MerchantDepositListAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
Expand Down Expand Up @@ -523,12 +523,9 @@ public async Task MerchantDomainService_MakeMerchantDeposit_NoDepositsYet_Deposi
this.AggregateService.Setup(e => e.Get<EstateAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate());

this.AggregateService.Setup(m => m.GetLatest<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
this.AggregateService.Setup(m => m.Get<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate()));
this.AggregateService
.Setup(m => m.Save(It.IsAny<MerchantAggregate>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success);


this.AggregateService
.Setup(m => m.GetLatest<MerchantDepositListAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantDepositListAggregate));
Expand Down Expand Up @@ -581,7 +578,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_EstateNotCreated_Erro
.Setup(m => m.Save(It.IsAny<MerchantAggregate>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success);

var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None);
Result result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None);
result.IsFailed.ShouldBeTrue();
}

Expand All @@ -590,12 +587,9 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_WithdrawalIsMade(
this.AggregateService.Setup(e => e.Get<EstateAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate());

this.AggregateService.Setup(m => m.GetLatest<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
this.AggregateService.Setup(m => m.Get<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate()));
this.AggregateService
.Setup(m => m.Save(It.IsAny<MerchantAggregate>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success);


this.AggregateService
.Setup(m => m.GetLatest<MerchantDepositListAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantDepositListAggregate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public MerchantStatementDomainServiceTests() {
this.StatementBuilder = new Mock<IStatementBuilder>();
this.MessagingServiceClient = new Mock<IMessagingServiceClient>();
this.SecurityServiceClient = new Mock<ISecurityServiceClient>();
this.DomainService = new MerchantStatementDomainService(this.AggregateService.Object, this.StatementBuilder.Object, this.MessagingServiceClient.Object, this.SecurityServiceClient.Object);
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.DomainService = new MerchantStatementDomainService(AggregateServiceResolver, this.StatementBuilder.Object, this.MessagingServiceClient.Object, this.SecurityServiceClient.Object);

IConfigurationRoot configurationRoot =
new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class OperatorDomainServiceTests{

public OperatorDomainServiceTests(){
this.AggregateService = new Mock<IAggregateService>();
this.OperatorDomainService = new OperatorDomainService(this.AggregateService.Object);
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.OperatorDomainService = new OperatorDomainService(AggregateServiceResolver);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class SettlementDomainServiceTests
public SettlementDomainServiceTests() {
this.AggregateService =
new Mock<IAggregateService>();

IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.settlementDomainService =
new SettlementDomainService(this.AggregateService.Object);
new SettlementDomainService(AggregateServiceResolver);

IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build();
ConfigurationReader.Initialise(configurationRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public TransactionDomainServiceTests(){
this.FeeCalculationManager = new Mock<IFeeCalculationManager>();
this.TransactionReceiptBuilder = new Mock<ITransactionReceiptBuilder>();
this.MessagingServiceClient = new Mock<IMessagingServiceClient>();

this.TransactionDomainService = new TransactionDomainService(this.AggregateService.Object,
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.TransactionDomainService = new TransactionDomainService(AggregateServiceResolver,
operatorProxyResolver,
this.TransactionValidationService.Object,
this.SecurityServiceClient.Object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public TransactionValidationServiceTests() {
this.SecurityServiceClient = new Mock<ISecurityServiceClient>();
this.EventStoreContext = new Mock<IEventStoreContext>();
this.AggregateService = new Mock<IAggregateService>();

IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Success(TestData.TokenResponse()));

this.TransactionValidationService = new TransactionValidationService(this.EventStoreContext.Object, this.AggregateService.Object);
this.TransactionValidationService = new TransactionValidationService(this.EventStoreContext.Object, AggregateServiceResolver);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ public VoucherDomainServiceTests() {
Logger.Initialise(NullLogger.Instance);

this.AggregateService = new Mock<IAggregateService>();
IAggregateService AggregateServiceResolver() => this.AggregateService.Object;
this.DbContextFactory = new Mock<IDbContextResolver<EstateManagementContext>>();
this.Context = this.GetContext(Guid.NewGuid().ToString("N"));
var services = new ServiceCollection();
services.AddTransient<EstateManagementContext>(_ => this.Context);
var serviceProvider = services.BuildServiceProvider();
var scope = serviceProvider.CreateScope();
this.DbContextFactory.Setup(d => d.Resolve(It.IsAny<String>(), It.IsAny<String>())).Returns(new ResolvedDbContext<EstateManagementContext>(scope));
this.VoucherDomainService = new VoucherDomainService(this.AggregateService.Object, DbContextFactory.Object);
this.VoucherDomainService = new VoucherDomainService(AggregateServiceResolver, DbContextFactory.Object);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ContractDomainService : IContractDomainService

#region Constructors

public ContractDomainService(IAggregateService aggregateService, IEventStoreContext context) {
this.AggregateService = aggregateService;
public ContractDomainService(Func<IAggregateService> aggregateService, IEventStoreContext context) {
this.AggregateService = aggregateService();
this.Context = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class EstateDomainService : IEstateDomainService

#region Constructors

public EstateDomainService(IAggregateService aggregateService,
public EstateDomainService(Func<IAggregateService> aggregateService,
ISecurityServiceClient securityServiceClient) {
this.AggregateService = aggregateService;
this.AggregateService = aggregateService();
this.SecurityServiceClient = securityServiceClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Task<Result> RecordTransaction(FloatActivityCommands.RecordTransactionCommand co
public class FloatDomainService : IFloatDomainService{
private readonly IAggregateService AggregateService;

public FloatDomainService(IAggregateService aggregateService)
public FloatDomainService(Func<IAggregateService> aggregateService)
{
this.AggregateService = aggregateService;
this.AggregateService = aggregateService();
}

private async Task<Result> ApplyFloatUpdates(Func<FloatAggregate, Result> action, Guid floatId, CancellationToken cancellationToken, Boolean isNotFoundError = true)
Expand Down
Loading
Loading