//Would be revisiting to modify the actual way of call method. public void TerminalDetailsInfoTest_TerminalSuccess() { // Arrange int lid = 191809; MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository(); var expectedResult = repository.GetMockTerminalDetails(); IOptions <DataContext> optionsAccessor = Substitute.For <IOptions <DataContext> >(); IDatabaseConnectionFactory connectionFactory = Substitute.For <IDatabaseConnectionFactory>(); ITerminalDetailsRepository mockRepo = Substitute.For <ITerminalDetailsRepository>(); mockRepo.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult.Result); // Act var actualRecord = mockRepo.GetTerminalDetails(lid).Result; // Assert Assert.Equal(actualRecord, expectedResult.Result); }
public ApiResult <EAndPData> GetTerminalDetails(int termNbr) { ApiResult <EAndPData> response = new ApiResult <EAndPData>(); try { var result = _terminalDetailsRepository.GetTerminalDetails(termNbr); response.Result = result.Result; } catch (System.Exception) { throw; } return(response); }
public void TerminalDetailsInfoApiTest_TerminalDetailsException() { // Arrange int CustomerID = 191809; IOptions <Settings> optionsAccessor = Substitute.For <IOptions <Settings> >(); ITerminalDetailsRepository mockRepo = Substitute.For <ITerminalDetailsRepository>(); ITerminalDetailsApi dashboardInfoApi = Substitute.For <ITerminalDetailsApi>(); mockRepo.GetTerminalDetails(CustomerID).ThrowsForAnyArgs(new Exception()); dashboardInfoApi = new TerminalDetailsApi(optionsAccessor, mockRepo, null); // Assert Assert.Throws <Exception>(() => dashboardInfoApi.GetTerminalDetails(CustomerID)); }
public void TerminalDetailsInfoApiTest_TerminalDetailsSuccess() { // Arrange int lid = 589547; MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository(); ITerminalDetailsRepository mockRepo = Substitute.For <ITerminalDetailsRepository>(); ITerminalDetailsSettlementInfoRepository mockSettlementRepo = Substitute.For <ITerminalDetailsSettlementInfoRepository>(); ITerminalDetailsApi api = Substitute.For <ITerminalDetailsApi>(); IOptions <Settings> appSettings = Substitute.For <IOptions <Settings> >(); var expectedResult = repository.GetMockTerminalDetails().Result; var expectedSettlementResult = repository.GetMockTerminalSettlementInfo().Result; mockRepo.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult); mockSettlementRepo.GetTerminalSettlementInfo(lid).ReturnsForAnyArgs(expectedSettlementResult); api = new TerminalDetailsApi(appSettings, mockRepo, mockSettlementRepo); // Act var actualRecord = (api.GetTerminalDetails(lid).Result); // Assert Assert.Equal((actualRecord), expectedResult); }