Exemplo n.º 1
0
        public async Task DashboardInfoControllerTest_GetDashBoardInfoSearch_GetAnException()
        {
            // Arrange
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalData();
            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();

            IDistributedCache mockCache = Substitute.For <IDistributedCache>();
            IStringLocalizer <DashboardInfoController> localizer
                = Substitute.For <IStringLocalizer <DashboardInfoController> >();
            string key             = "GetDashboardInfoErrorMessage";
            string value           = "Test Localized String";
            var    localizedString = new LocalizedString(key, value);

            localizer[Arg.Any <string>()].ReturnsForAnyArgs(localizedString);
            IOperation          fakeOperation = FakeOperation(_cache);
            IOptions <Settings> appSettings   = Substitute.For <IOptions <Settings> >();
            ILoggingFacade      fakeLogger    = FakeLogger();
            IDashboardInfoApi   dAPI          = new DashboardInfoApi(appSettings, mockRepo);

            dAPI.GetDashboardSearchResultsPagination(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, 0).Throws(new Exception());
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);


            // Act
            var dinfo = await controller.GetDashBoardInfoSearch(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, "0");

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

            // Assert
            Assert.Equal(actualRecord.StatusCode, 500);
            Assert.Equal(actualRecord.Value, "Test Localized String");
        }
Exemplo n.º 2
0
        public async Task DashboardInfoControllerTest_MerchantSuccess()
        {
            // Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockMerchantData();

            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();
            IOperation fakeOperation          = FakeOperation(_cache);

            ILoggingFacade    fakeLogger = FakeLogger();
            IDashboardInfoApi dAPI       = Substitute.For <IDashboardInfoApi>();

            dAPI.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.MerchantNbr, lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);

            // Act
            var dinfo = await controller.Get(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.MerchantNbr, lid);

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

            // Assert
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).MerchInfo.customerID, 393727);
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).CustProfile.customerID, 393727);
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).TermInfo, null);
        }
Exemplo n.º 3
0
        public void DashboardInfoControllerTest_GetDashBoardInfoSearch_ModelState_Invalid()
        {
            //Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalData();

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

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

            fakeOperation.WhenForAnyArgs(x => x.RetrieveCache(Arg.Any <string>(), Arg.Any <Wp.CIS.LynkSystems.Model.DashboardInfo>())).DoNotCallBase();
            dAPI.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);

            //Act
            controller.ModelState.AddModelError("key", "error message");
            var dinfo = controller.GetDashBoardInfoSearch(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.TerminalNbr, Convert.ToString(lid)).Result;

            //Assert
            Assert.Equal(((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).StatusCode.ToString(), "400");
        }
Exemplo n.º 4
0
        public async Task DashboardInfoControllerTerminalDetailsTest_GetAnException()
        {
            // Arrange
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();
            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();

            IDistributedCache mockCache = Substitute.For <IDistributedCache>();
            IStringLocalizer <DashboardInfoController> localizer
                = Substitute.For <IStringLocalizer <DashboardInfoController> >();
            string key             = "GenericError";
            string value           = "Error occured";
            var    localizedString = new LocalizedString(key, value);

            localizer[Arg.Any <string>()].ReturnsForAnyArgs(localizedString);
            IOperation          fakeOperation = FakeOperation(_cache);
            IOptions <Settings> appSettings   = Substitute.For <IOptions <Settings> >();
            ILoggingFacade      fakeLogger    = FakeLogger();
            IDashboardInfoApi   dAPI          = new DashboardInfoApi(appSettings, mockRepo);

            dAPI.GetTerminalDetails(0).ThrowsForAnyArgs(new System.Exception());
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);


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

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

            // Assert
            Assert.Equal(actualRecord.StatusCode, 500);
            Assert.Equal(actualRecord.Value, "Error occured");
        }
Exemplo n.º 5
0
        public async Task DashboardInfoControllerTest_MerchantAccountSuccess()
        {
            // Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockMerchantData();

            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();
            IOperation        fakeOperation   = FakeOperation(_cache);
            ILoggingFacade    fakeLogger      = FakeLogger();
            IDashboardInfoApi dAPI            = Substitute.For <IDashboardInfoApi>();

            dAPI.GetDashboardSearchResults(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.MerchantNbr, lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);

            // Act
            var dinfo = await controller.Get(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.MerchantNbr, lid);

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

            // Assert
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).DemographicsInfoCust, repository.custDemographicsList);
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).DemographicsInfoMerch, repository.merchDemographicsList);
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).DemographicsInfoTerm, null);
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).MerchInfo.merchFedTaxID, "561005071");
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).MerchInfo.acquiringBank, "Citizens Trust Tier 1 Tier 2");
        }
Exemplo n.º 6
0
        public async Task DashboardInfoControllerTest_GetDashBoardInfoSearch_Success()
        {
            // Arrange
            int lid = 589547;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockCustomerData();

            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();
            IOperation        fakeOperation   = FakeOperation(_cache);
            ILoggingFacade    fakeLogger      = FakeLogger();
            IDashboardInfoApi dAPI            = Substitute.For <IDashboardInfoApi>();

            dAPI.GetDashboardSearchResultsPagination(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);
            // Act
            var dinfo = await controller.GetDashBoardInfoSearch(Wp.CIS.LynkSystems.Model.Helper.LIDTypes.CustomerNbr, Convert.ToString(lid));

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

            // Assert
            Assert.Equal(((Wp.CIS.LynkSystems.Model.DashboardInfo)actualRecord).DemographicsInfoCust, repository.custDemographicsList);
        }
Exemplo n.º 7
0
        public async Task DashboardInfoControllerTest_TerminalDetailsAccountSuccess()
        {
            // Arrange
            int lid = 588799;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();

            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();
            IOperation        fakeOperation   = FakeOperation(_cache);
            ILoggingFacade    fakeLogger      = FakeLogger();
            IDashboardInfoApi dAPI            = Substitute.For <IDashboardInfoApi>();

            dAPI.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _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.TerminalDetails)actualRecord), expectedResult.Result);
        }