public void SpreadMarketServicePropertyLazyLoadsTheServiceTheFirstTimeItsCalled() { // Arrange var serviceReturned = new SpreadMarketService(new SpreadMarketsQuery(_mockApiConnection.CoreConnection)); _spreadMarketServiceFactory.Expect(x => x.Create(_mockApiConnection)) .Return(serviceReturned) .Repeat.Once(); // Act var service = _serviceManager.SpreadMarketService; var serviceSecondCall = _serviceManager.SpreadMarketService; // Assert Assert.AreEqual(serviceReturned, service); Assert.AreEqual(service, serviceSecondCall); _mockNewsServiceFactory.VerifyAllExpectations(); }
public void ListSpreadMarketsCallsTheCorrectMethodFromTheUnderlyingCore() { //Arrange const string query = "query"; const bool searchByMarketName = true; const bool searchByMarketCode = false; const int clientAccount = 34234; const int maxResults = 10; var mockSpreadMarketsQuery = MockRepository.GenerateMock <SpreadMarketsQuery>(_mockConnection); mockSpreadMarketsQuery.Expect(x => x.ListSpreadMarkets(query, searchByMarketName, searchByMarketCode, clientAccount, maxResults)) .Return(new ListSpreadMarketsResponseDTO(new List <ApiMarketDTO>())); //Act var response = new SpreadMarketService(mockSpreadMarketsQuery).ListSpreadMarkets(query, searchByMarketName, searchByMarketCode, clientAccount, maxResults); //Assert Assert.IsInstanceOfType(typeof(ListSpreadMarketsResponseDTO), response); mockSpreadMarketsQuery.VerifyAllExpectations(); }