Exemplo n.º 1
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.º 2
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.º 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 <IActionResult> Get(Model.Helper.LIDTypes LIDType, int LID)
        {
            await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting Dashboard Info Get " + LIDType + ", " + LID, "DashboardInfoController.cs", "Get"), CancellationToken.None);

            if (!ModelState.IsValid)
            {
                await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "DashboardInfoController.cs", "Get"), CancellationToken.None);

                return(BadRequest(ModelState));
            }

            try
            {
                string key  = "dashboardInfo_" + LID.ToString();
                var    data = _operation.RetrieveCache(key, new DashboardInfo());
                if (data == null)
                {
                    //since no data in cache, now get data from DB
                    var result = await _dashboardInfo.GetDashboardSearchResults(LIDType, LID);

                    data = result.Result;
                    //Now add data to cache..
                    await _operation.AddCacheAsync(key, data);
                }
                if (data == null)
                {
                    var msg = this._localizer["NoDataFound"]?.Value;
                    await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "DashboardInfoController.cs", "Get"), CancellationToken.None);

                    return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg));
                }
                await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Dashboard Info Get Successful", "DashboardInfoController.cs", "Get"), CancellationToken.None);

                return(Ok(data));
            }
            catch (Exception ex)
            {
                var msg = this._localizer?["GetDashboardInfoErrorMessage"]?.Value;
                await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetDashBoardInfoGet()", CancellationToken.None);

                return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg));
            }
        }