예제 #1
0
        public void DashboardInfoTest_TerminalDetailsSuccess()
        {
            // Arrange
            int lid = 589547;

            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();
            IDashboardInfoRepository mockRepo = Substitute.For <IDashboardInfoRepository>();

            mockRepo.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult.Result);

            // Act
            var actualRecord = mockRepo.GetTerminalDetails(lid).Result;

            // Assert
            Assert.Equal((actualRecord), expectedResult.Result);
        }
예제 #2
0
        public async Task <ApiResult <TerminalDetails> > GetTerminalDetails(int termNbr)
        {
            ApiResult <TerminalDetails> response = new ApiResult <TerminalDetails>();

            try
            {
                response.Result = await _dashboardRepository.GetTerminalDetails(termNbr);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(response);
        }
예제 #3
0
        public async Task DashboardInfoApiTest_TerminalDetailsException()
        {
            // Arrange
            int CustomerID = 191809;

            // IOptions<Settings> optionsAccessor = Options.Create(appSettings);
            IOptions <Settings>      optionsAccessor  = Substitute.For <IOptions <Settings> >();
            IDashboardInfoRepository mockRepo         = Substitute.For <IDashboardInfoRepository>();
            IDashboardInfoApi        dashboardInfoApi = Substitute.For <IDashboardInfoApi>();

            mockRepo.GetTerminalDetails(CustomerID).ThrowsForAnyArgs(new Exception());
            dashboardInfoApi = new DashboardInfoApi(optionsAccessor, mockRepo);


            // Assert

            await Assert.ThrowsAsync <Exception>(() => dashboardInfoApi.GetTerminalDetails(CustomerID));
        }
예제 #4
0
        public void DashboardInfoApiTest_TerminalDetailsSuccess()
        {
            // Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();

            IDashboardInfoRepository mockRepo    = Substitute.For <IDashboardInfoRepository>();
            IDashboardInfoApi        api         = Substitute.For <IDashboardInfoApi>();
            IOptions <Settings>      appSettings = Substitute.For <IOptions <Settings> >();

            var expectedResult = repository.GetMockTerminalDetails().Result;

            mockRepo.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            api = new DashboardInfoApi(appSettings, mockRepo);

            // Act
            var actualRecord = (api.GetTerminalDetails(lid).Result).Result;

            // Assert
            Assert.Equal((actualRecord), expectedResult);
        }