public void GetClientAndTradingAccountCallsTheCorrectMethodFromTheUnderlyingCore() { //Arrange var mockConnection = MockRepository.GenerateMock<Connection>("username", "password", "http://couldBeAnyUrl/TradingApi"); var mockAccountInformationQuery = MockRepository.GenerateMock<AccountInformationQuery>(mockConnection); mockAccountInformationQuery.Expect(x => x.GetClientAndTradingAccount()) .Return(new AccountInformationResponseDTO()); //Act var response = new AccountInformationService(mockAccountInformationQuery).GetClientAndTradingAccount(); //Assert Assert.IsInstanceOfType(typeof(AccountInformationResponseDTO), response); mockAccountInformationQuery.VerifyAllExpectations(); }
public void AccountInformationServicePropertyLazyLoadsTheServiceTheFirstTimeItsCalled() { // Arrange var expectedAccountServiceReturned = new AccountInformationService(new AccountInformationQuery(_mockApiConnection.CoreConnection)); _mockAccountInformationServiceFactory.Expect(x => x.Create(_mockApiConnection)) .Return(expectedAccountServiceReturned) .Repeat.Once(); // Act var accountInfoService = _serviceManager.AccountInformationService; var accountInfoServiceSecondCall = _serviceManager.AccountInformationService; // Assert Assert.AreEqual(expectedAccountServiceReturned, accountInfoService); Assert.AreEqual(accountInfoService, accountInfoServiceSecondCall); _mockAccountInformationServiceFactory.VerifyAllExpectations(); }