Example #1
0
        public async Task TerminalDetailsControllerTest_TerminalSuccess()
        {
            // Arrange
            int lid = 589547;
            MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();

            ITerminalDetailsRepository mockRepo = FakeRepository();
            IDistributedCache          _cache   = FakeCache();
            IOperation     fakeOperation        = FakeOperation(_cache);
            ILoggingFacade fakeLogger           = FakeLogger();

            ITerminalDetailsApi dAPI = Substitute.For <ITerminalDetailsApi>();

            dAPI.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            TerminalDetailsController controller = FakeController(dAPI, _cache, fakeOperation, fakeLogger);

            // Act
            var dinfo = await controller.GetTerminalDetails(lid);

            var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;

            // Assert
            Assert.Equal(((Wp.CIS.LynkSystems.Model.EAndPData)actualRecord), expectedResult.Result);
        }
        //Would be revisiting to modify the actual way of call method.
        public void TerminalDetailsInfoTest_TerminalSuccess()
        {
            // Arrange
            int lid = 191809;

            MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();
            IOptions <DataContext>     optionsAccessor   = Substitute.For <IOptions <DataContext> >();
            IDatabaseConnectionFactory connectionFactory = Substitute.For <IDatabaseConnectionFactory>();
            ITerminalDetailsRepository mockRepo          = Substitute.For <ITerminalDetailsRepository>();

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

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

            // Assert

            Assert.Equal(actualRecord, expectedResult.Result);
        }
Example #3
0
        public void TerminalDetailsControllerTest_ModelState_Invalid()
        {
            //Arrange
            int lid = 589547;
            MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();

            ITerminalDetailsRepository mockRepo = FakeRepository();
            IDistributedCache          _cache   = FakeCache();
            IOperation     fakeOperation        = FakeOperation(_cache);
            ILoggingFacade fakeLogger           = FakeLogger();

            ITerminalDetailsApi dAPI = Substitute.For <ITerminalDetailsApi>();

            dAPI.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            TerminalDetailsController controller = FakeController(dAPI, _cache, fakeOperation, fakeLogger);

            //Act
            controller.ModelState.AddModelError("key", "error message");
            var dinfo = controller.GetTerminalDetails(lid).Result;

            //Assert
            Assert.Equal(((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).StatusCode.ToString(), "400");
        }
Example #4
0
        public void TerminalDetailsInfoApiTest_TerminalDetailsSuccess()
        {
            // Arrange
            int lid = 589547;
            MockTerminalDetailsInfoRepository repository = new MockTerminalDetailsInfoRepository();

            ITerminalDetailsRepository mockRepo = Substitute.For <ITerminalDetailsRepository>();
            ITerminalDetailsSettlementInfoRepository mockSettlementRepo = Substitute.For <ITerminalDetailsSettlementInfoRepository>();
            ITerminalDetailsApi api         = Substitute.For <ITerminalDetailsApi>();
            IOptions <Settings> appSettings = Substitute.For <IOptions <Settings> >();

            var expectedResult           = repository.GetMockTerminalDetails().Result;
            var expectedSettlementResult = repository.GetMockTerminalSettlementInfo().Result;

            mockRepo.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            mockSettlementRepo.GetTerminalSettlementInfo(lid).ReturnsForAnyArgs(expectedSettlementResult);
            api = new TerminalDetailsApi(appSettings, mockRepo, mockSettlementRepo);

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

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