public void ListCfdMarketsCallsTheCorrectMethodFromTheUnderlyingCore() { //Arrange const string query = "query"; const bool searchByMarketName = true; const bool searchByMarketCode = false; const int clientAccount = 34234; const int maxResults = 10; var mockConnection = MockRepository.GenerateMock<Connection>("username", "password", "http://couldBeAnyUrl/TradingApi"); var mockCfdMarketQuery = MockRepository.GenerateMock<CfdMarketQuery>(mockConnection); mockCfdMarketQuery.Expect(x => x.ListCfdMarkets(query, searchByMarketName, searchByMarketCode, clientAccount, maxResults)) .Return(new ListCfdMarketsResponseDTO(new List<ApiMarketDTO>())); //Act var response = new CfdMarketService(mockCfdMarketQuery).ListCfdMarkets(query, searchByMarketName, searchByMarketCode, clientAccount, maxResults); //Assert Assert.IsInstanceOfType(typeof(ListCfdMarketsResponseDTO), response); mockCfdMarketQuery.VerifyAllExpectations(); }
public void CfdMarketServicePropertyLazyLoadsTheServiceTheFirstTimeItsCalled() { // Arrange var expectedCfdMarketServiceReturned = new CfdMarketService(new CfdMarketQuery(_mockApiConnection.CoreConnection)); _mockCfdMarketServiceFactory.Expect(x => x.Create(_mockApiConnection)) .Return(expectedCfdMarketServiceReturned) .Repeat.Once(); // Act var cfdMarketService = _serviceManager.CfdMarketService; var cfdMarketServiceSecondCall = _serviceManager.CfdMarketService; // Assert Assert.AreEqual(expectedCfdMarketServiceReturned, cfdMarketService); Assert.AreEqual(cfdMarketService, cfdMarketServiceSecondCall); _mockAccountInformationServiceFactory.VerifyAllExpectations(); }