Exemplo n.º 1
0
        public async Task UpdateEPSMappingTest_Fail()
        {
            MockEPSMappingApiRepository api         = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi epsMappingApi            = new EPSMappingApi(appSettings, api);
            var            localizer = new MockStringLocalizer <EPSMappingController>();

            localizer[0] = new LocalizedString("EPSMappingTable_FieldNameErrorMsg", "Worldpay Table/Field name are mandatory");
            EPSMappingController controller = FakeController(_cache, epsMappingApi, localizer);

            //.. Act
            var dinfo = await controller.Update(new EPSMapping());

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

            //..Assert
            Assert.Equal(actualRecord.StatusCode, (int)System.Net.HttpStatusCode.BadRequest);
            Assert.Equal(actualRecord.Value, "Worldpay Table/Field name are mandatory");
        }
Exemplo n.º 2
0
        public async Task UpdateEPSMappingVersionDetailsTest_Success()
        {
            MockEPSMappingApiRepository api         = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi       epsMappingApi      = new EPSMappingApi(appSettings, api);
            EPSMappingController controller         = FakeController(_cache, epsMappingApi);
            EPSMapping           epsMapping         = new EPSMapping();

            epsMapping.versionID                = 3;
            epsMapping.mappingID                = 399;
            epsMapping.pdlFlag                  = true;
            epsMapping.paramName                = "Test";
            epsMapping.paramID                  = 200;
            epsMapping.worldPayFieldName        = null;
            epsMapping.worldPayTableName        = null;
            epsMapping.worldPayJoinFields       = null;
            epsMapping.worldPayCondition        = null;
            epsMapping.worldPayOrderBy          = null;
            epsMapping.worldPayFieldDescription = "Master Cutoff Amount2";
            epsMapping.effectiveBeginDate       = DateTime.Now;
            epsMapping.effectiveEndDate         = DateTime.Now;
            epsMapping.viperTableName           = "Fee";
            epsMapping.viperFieldName           = "/ FeeRow / FeeAmount";
            epsMapping.viperCondition           = null;
            epsMapping.charStartIndex           = 103;
            epsMapping.charLength               = 3;
            epsMapping.createdByUser            = "******";
            //.. Act
            var dinfo = await controller.Update(epsMapping);

            var actualRecord   = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;
            var updatedMapping = api.epsMapping.Where(s => s.versionID == 3).FirstOrDefault();

            //..Assert
            Assert.Equal(epsMapping.pdlFlag, true);
            Assert.Equal(updatedMapping, epsMapping);
        }