Пример #1
0
        //Would be revisiting to modify the actual way of call method.
        public void ActiveServicesTest_Success()
        {
            // Arrange
            int lid = 191809;

            MockActiveServicesRepository repository = new MockActiveServicesRepository();
            var expectedResult = repository.GetMockData();
            IOptions <DataContext>     optionsAccessor   = Substitute.For <IOptions <DataContext> >();
            IDatabaseConnectionFactory connectionFactory = Substitute.For <IDatabaseConnectionFactory>();
            IActiveServicesRepository  mockRepo          = Substitute.For <IActiveServicesRepository>();

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

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

            // Assert
            Assert.Equal((actualRecord), expectedResult.Result);
        }
Пример #2
0
        public async Task <ApiResult <ICollection <ActiveServices> > > GetActiveServices(int LIDType, int LID)
        {
            ApiResult <ICollection <ActiveServices> > response = new ApiResult <ICollection <ActiveServices> >();

            try
            {
                response.Result = await _activeServicesRepository.GetActiveServices(LIDType, LID);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(response);
        }
Пример #3
0
        public async Task ActiveServicesApiTest_Exception()
        {
            // Arrange
            int CustomerID = 191809;

            IOptions <Settings>       optionsAccessor   = Substitute.For <IOptions <Settings> >();
            IActiveServicesRepository mockRepo          = Substitute.For <IActiveServicesRepository>();
            IActiveServicesApi        activeServicesApi = Substitute.For <IActiveServicesApi>();

            mockRepo.GetActiveServices((int)Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerID, CustomerID).ThrowsForAnyArgs(new Exception());
            activeServicesApi = new ActiveServicesApi(optionsAccessor, mockRepo);

            // Act
            //var result = activeServicesApi.GetActiveServices((int)Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerID, CustomerID).Result;
            await Assert.ThrowsAsync <Exception>(() => activeServicesApi.GetActiveServices((int)Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerID, CustomerID));

            // Assert
            //Assert.Equal(((IList<string>)result.ErrorMessages).First(), "InternalServerError");
        }
Пример #4
0
        public void ActiveServicesApiTest_Success()
        {
            // Arrange
            int lid = 589547;
            IOptions <Settings>       optionsAccessor = Substitute.For <IOptions <Settings> >();
            IActiveServicesRepository mockRepo        = Substitute.For <IActiveServicesRepository>();
            IActiveServicesApi        api             = Substitute.For <IActiveServicesApi>();

            MockActiveServicesRepository repository = new MockActiveServicesRepository();
            var expectedResult = repository.GetMockData().Result;

            mockRepo.GetActiveServices((int)Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult);

            api = new ActiveServicesApi(optionsAccessor, mockRepo);

            // Act
            var actualRecord = (api.GetActiveServices((int)Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, lid).Result).Result;

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