public void GetMarketInfoCallsTheCorrectMethodFromTheUnderlyingMarketInformationQueryClass() { //Arrange const int marketId = 5; var mockMarketInformationQuery = MockRepository.GenerateMock <MarketInformationQuery>(_mockConnection); mockMarketInformationQuery.Expect(x => x.GetMarketInformation(marketId)) .Return(new GetMarketInformationResponseDTO()); //Act var response = new MarketInformationService(mockMarketInformationQuery).GetMarketInformation(marketId); //Assert Assert.IsInstanceOfType(typeof(GetMarketInformationResponseDTO), response); mockMarketInformationQuery.VerifyAllExpectations(); }
public void MarketInformationServicePropertyLazyLoadsTheServiceTheFirstTimeItsCalled() { // Arrange var expectedMarketServiceReturned = new MarketInformationService(new MarketInformationQuery(_mockApiConnection.CoreConnection)); _mockMarketInformationServiceFactory.Expect(x => x.Create(_mockApiConnection)) .Return(expectedMarketServiceReturned) .Repeat.Once(); // Act var marketService = _serviceManager.MarketInformationService; var marketServiceSecondCall = _serviceManager.MarketInformationService; // Assert Assert.AreEqual(expectedMarketServiceReturned, marketService); Assert.AreEqual(marketService, marketServiceSecondCall); _mockMarketInformationServiceFactory.VerifyAllExpectations(); }