public GetBalanceTests() { var entityLockerMock = new Mock <IEntityLocker>(); entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success())); var edoContextMock = MockEdoContextFactory.Create(); var mockedEdoContext = edoContextMock.Object; _agencyAccountService = new AgencyAccountService(mockedEdoContext, entityLockerMock.Object, Mock.Of <IManagementAuditService>(), Mock.Of <IAccountBalanceAuditService>()); var strategy = new ExecutionStrategyMock(); var dbFacade = new Mock <DatabaseFacade>(mockedEdoContext); dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy); edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object); edoContextMock .Setup(c => c.Agencies) .Returns(DbSetMockProvider.GetDbSetMock(new List <Agency> { new Agency { Id = 1 }, // Having more than one element for predicates to be tested too new Agency { Id = 2 }, })); edoContextMock .Setup(c => c.AgencyAccounts) .Returns(DbSetMockProvider.GetDbSetMock(new List <AgencyAccount> { new AgencyAccount { Id = 1, Balance = 1000, Currency = Currencies.USD, AgencyId = 1, IsActive = true }, new AgencyAccount { Id = 1, Balance = 0, Currency = Currencies.USD, AgencyId = 1, IsActive = true } })); }
public AddMoneyTests() { var entityLockerMock = new Mock <IEntityLocker>(); entityLockerMock.Setup(l => l.Acquire <It.IsAnyType>(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Result.Success())); _edoContextMock = MockEdoContextFactory.Create(); _mockedEdoContext = _edoContextMock.Object; _agencyAccountService = new AgencyAccountService(_mockedEdoContext, entityLockerMock.Object, Mock.Of <IManagementAuditService>(), Mock.Of <IAccountBalanceAuditService>()); var strategy = new ExecutionStrategyMock(); var dbFacade = new Mock <DatabaseFacade>(_mockedEdoContext); dbFacade.Setup(d => d.CreateExecutionStrategy()).Returns(strategy); _edoContextMock.Setup(c => c.Database).Returns(dbFacade.Object); }