Beispiel #1
0
        public void DashboardInfoApiTest_CustomerSuccess()
        {
            // Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();

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


            var appSettings = new Settings()
            {
                MaxNumberOfRecordsToReturn = maxRecordsToReturn
            };
            IOptions <Settings> options = Options.Create(appSettings);

            var expectedResult = repository.GetMockCustomerData().Result;

            mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, lid, maxRecordsToReturn).ReturnsForAnyArgs(expectedResult);

            api = new DashboardInfoApi(options, mockRepo);

            // Act
            var actualRecord = (api.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, lid).Result).Result;

            // Assert
            Assert.Equal((actualRecord), expectedResult);
            Assert.Equal((actualRecord).MerchInfo, null);
            Assert.Equal((actualRecord).CustProfile.customerID, 393727);
            Assert.Equal((actualRecord).TermInfo, null);
        }
        public void DashboardInfoTest_CustomerSuccess()
        {
            // Arrange
            int lid = 589547;

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

            mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, lid, maxRecordsToReturn).ReturnsForAnyArgs(expectedResult.Result);

            // Act
            var actualRecord = mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, lid, maxRecordsToReturn).Result;

            // Assert
            Assert.Equal((actualRecord).MerchInfo, null);
            Assert.Equal((actualRecord).CustProfile.customerID, 393727);
            Assert.Equal((actualRecord).TermInfo, null);
        }
        //Would be revisiting to modify the actual way of call method.
        public void DashboardInfoTest_TerminalSuccess()
        {
            // Arrange
            int lid = 191809;

            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalData();
            IOptions <DataContext>     optionsAccessor   = Substitute.For <IOptions <DataContext> >();
            IDatabaseConnectionFactory connectionFactory = Substitute.For <IDatabaseConnectionFactory>();
            IDashboardInfoRepository   mockRepo          = Substitute.For <IDashboardInfoRepository>();

            mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, lid, maxRecordsToReturn).ReturnsForAnyArgs(expectedResult.Result);

            // Act
            var actualRecord = mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, lid, maxRecordsToReturn).Result;

            // Assert

            Assert.Equal((actualRecord).MerchInfo.customerID, 393727);
            Assert.Equal((actualRecord).CustProfile.customerID, 393727);
            Assert.Equal((actualRecord).TermInfo.customerID, 393727);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="LIDtype"></param>
        /// <param name="LID"></param>
        /// <returns></returns>
        async Task <ApiResult <DashboardInfo> > IDashboardInfoApi.GetDashboardSearchResults(Helper.LIDTypes LIDtype, int LID)
        {
            ApiResult <DashboardInfo> response = new ApiResult <DashboardInfo>();

            try
            {
                response.Result = await _dashboardRepository.GetDashboardSearchResults(LIDtype, LID, this._optionsAccessor.Value.MaxNumberOfRecordsToReturn);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(response);
        }
Beispiel #5
0
        public async Task DashboardInfoApiTest_Exception()
        {
            // Arrange
            int CustomerID = 191809;

            var appSettings = new Settings()
            {
                MaxNumberOfRecordsToReturn = maxRecordsToReturn
            };
            IOptions <Settings>      optionsAccessor  = Options.Create(appSettings);
            IDashboardInfoRepository mockRepo         = Substitute.For <IDashboardInfoRepository>();
            IDashboardInfoApi        dashboardInfoApi = Substitute.For <IDashboardInfoApi>();

            mockRepo.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerID, CustomerID, maxRecordsToReturn).ThrowsForAnyArgs(new Exception());
            dashboardInfoApi = new DashboardInfoApi(optionsAccessor, mockRepo);


            // Assert
            await Assert.ThrowsAsync <Exception>(() => dashboardInfoApi.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerID, CustomerID));
        }