Esempio n. 1
0
        //Would be revisiting to modify the actual way of call method.
        public void CaseHistoryControllerTest_Success()
        {
            // Arrange
            LidTypeEnum           LIDType = LidTypeEnum.CustomerNbr;
            string                LID     = "";
            PaginationCaseHistory page    = new PaginationCaseHistory();

            string ExtraId = null;
            int    lid     = 648988;
            int    CaseID  = 8715123;

            MockCaseHistoryRepository mockCaseHistoryRepository = new MockCaseHistoryRepository();
            ApiResult <GenericPaginationResponse <Wp.CIS.LynkSystems.Model.CaseHistory> > expectedResult = mockCaseHistoryRepository.GetMockData(lid);

            IOptions <DataContext>     optionsAccessor   = Substitute.For <IOptions <DataContext> >();
            IDatabaseConnectionFactory connectionFactory = Substitute.For <IDatabaseConnectionFactory>();

            ICaseHistoryRepository mockRepo = Substitute.For <ICaseHistoryRepository>();

            mockRepo.GetCaseHistoryInfo(LIDType, LID, ExtraId, page).ReturnsForAnyArgs(expectedResult.Result);

            // Act
            var caseHistory = mockRepo.GetCaseHistoryInfo(LIDType, "648988", ExtraId, page).Result;

            var actualRecord = (IList <Wp.CIS.LynkSystems.Model.CaseHistory>)caseHistory.ReturnedRecords;

            string caseInfo = actualRecord.Where(x => x.caseId == CaseID).FirstOrDefault().caseLevel;

            //// Assert

            Assert.Equal(((IList <Wp.CIS.LynkSystems.Model.CaseHistory>)actualRecord).Count, 6);

            Assert.Equal(caseInfo, "Customer");
        }
Esempio n. 2
0
        public async Task CaseHistoryApiTest_Exception()
        {
            // Arrange
            LidTypeEnum LIDType = LidTypeEnum.CustomerNbr;
            string      LID     = "";

            PaginationCaseHistory page = new PaginationCaseHistory();

            int lid = 648988;

            string ExtraId = null;


            MockCaseHistoryRepository mockCaseHistoryRepository = new MockCaseHistoryRepository();
            ApiResult <GenericPaginationResponse <Wp.CIS.LynkSystems.Model.CaseHistory> > expectedResult = mockCaseHistoryRepository.GetMockData(lid);

            IOptions <Settings> optionsAccessor = Substitute.For <IOptions <Settings> >();

            ICaseHistoryRepository mockRepo = Substitute.For <ICaseHistoryRepository>();

            ICaseHistoryApi casehistoryApi = Substitute.For <ICaseHistoryApi>();

            IDistributedCache mockCache = Substitute.For <IDistributedCache>();

            mockRepo.GetCaseHistoryInfo(LIDType, LID, ExtraId, page).Throws(new Exception());

            casehistoryApi = new CaseHistoryApi(optionsAccessor, mockRepo);

            //Assert
            await Assert.ThrowsAsync <Exception>(() => casehistoryApi.GetCaseHistory(LIDType, LID, ExtraId, page));
        }
Esempio n. 3
0
        public async Task <ApiResult <GenericPaginationResponse <CaseHistory> > > GetCaseHistory(LidTypeEnum lidtype, string lid, string extraId, PaginationCaseHistory page)
        {
            ApiResult <GenericPaginationResponse <CaseHistory> > response = new ApiResult <GenericPaginationResponse <CaseHistory> >();

            try
            {
                response.Result = await _casehistoryrepository.GetCaseHistoryInfo(lidtype, lid, extraId, page);
            }
            catch (Exception)
            {
                throw;
            }
            return(response);
        }