Пример #1
0
        public void TestBankingInfoRepository_Success()
        {
            MockBankingInfoRepository repository = new MockBankingInfoRepository();
            var expectedResult = repository.GetMockBankingInfo();


            string lid = "756122";
            IBankingInfoRepository mockRepo = Substitute.For <IBankingInfoRepository>();

            mockRepo.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult.Result);

            // Act
            var actualRecord = mockRepo.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).Result;

            // Assert
            Assert.Equal((actualRecord), expectedResult.Result);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="LIDType"></param>
        /// <param name="LID"></param>
        /// <returns></returns>
        public async Task <ApiResult <ICollection <BankingInformation> > > GetBankingInfo(Helper.LIDTypes LIDType, string LID)
        {
            ApiResult <ICollection <BankingInformation> > response = new ApiResult <ICollection <BankingInformation> >();

            try
            {
                response.Result = await _bankingRepository.GetBankingInfo(LIDType, LID);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(response);
        }
Пример #3
0
        public async Task BankingInfoApiTest_Exception()
        {
            // Arrange
            string lid = "191809";

            IOptions <Settings>    optionsAccessor = Substitute.For <IOptions <Settings> >();
            IBankingInfoRepository mockRepo        = Substitute.For <IBankingInfoRepository>();
            IBankingApi            bankingInfoApi  = Substitute.For <IBankingApi>();

            mockRepo.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ThrowsForAnyArgs(new Exception());
            bankingInfoApi = new BankingApi(optionsAccessor, mockRepo);

            // Assert
            await Assert.ThrowsAsync <Exception>(() => bankingInfoApi.GetBankingInfo(Helper.LIDTypes.TerminalNbr, "0"));
        }
Пример #4
0
        public void TestBankingInfoApi_Success()
        {
            //Arrange
            MockBankingInfoRepository repository = new MockBankingInfoRepository();
            var expectedResult = repository.GetMockBankingInfo();

            string lid = "756122";

            IBankingInfoRepository mockRepo    = Substitute.For <IBankingInfoRepository>();
            IBankingApi            api         = Substitute.For <IBankingApi>();
            IOptions <Settings>    appSettings = Substitute.For <IOptions <Settings> >();

            mockRepo.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult.Result);
            api = new BankingApi(appSettings, mockRepo);

            // Act
            var actualRecord = api.GetBankingInfo(Helper.LIDTypes.TerminalNbr, lid).Result;

            //Assert
            Assert.Equal(((IList <BankingInformation>)actualRecord.Result), (IList <BankingInformation>)expectedResult.Result);
        }