Exemplo n.º 1
0
        public async Task InsertEPSMappingTest_Success()
        {
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi       epsMappingApi      = new EPSMappingApi(appSettings, bApi);
            EPSMappingController controller         = FakeController(_cache, epsMappingApi);
            EPSMapping           epsMapping         = new EPSMapping();

            epsMapping.versionID                = 1;
            epsMapping.pdlFlag                  = false;
            epsMapping.paramID                  = 200;
            epsMapping.worldPayFieldName        = "PrimaryPhoneNbr";
            epsMapping.worldPayTableName        = "tbTranSurcharge";
            epsMapping.worldPayJoinFields       = null;
            epsMapping.worldPayCondition        = null;
            epsMapping.worldPayOrderBy          = null;
            epsMapping.worldPayFieldDescription = "Master Cutoff Amount1";
            epsMapping.effectiveBeginDate       = DateTime.Now;
            epsMapping.effectiveEndDate         = DateTime.Now;
            epsMapping.viperTableName           = "Fee";
            epsMapping.viperFieldName           = "/ Fee / FeeRow / FeeAmount";
            epsMapping.viperCondition           = "Fee";
            epsMapping.charStartIndex           = 102;
            epsMapping.charLength               = 3;
            epsMapping.createdByUser            = "******";
            //.. Act
            var dinfo = await controller.Post(epsMapping);

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

            //..Assert
            Assert.Equal(((bool)actualRecord), true);
        }
Exemplo n.º 2
0
        public async Task CopyEpsMappingAsync_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);

            //.. Act
            var dinfo = await controller.Copy(new EPSCopyMapping()
            {
                FromVersionID = 1, ToVersionID = 2
            });

            var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;
            var fromMapping  = api.epsMapping.Where(s => s.versionID == 1).
                               Select(s => new { s.pdlFlag, s.worldPayFieldName, s.worldPayTableName, s.worldPayJoinFields, s.worldPayCondition, s.worldPayOrderBy, s.worldPayFieldDescription, s.paramID, s.effectiveBeginDate, s.effectiveEndDate, s.viperCondition, s.viperFieldName, s.viperTableName, s.charStartIndex, s.charLength }).ToList();
            var toMapping = api.epsMapping.Where(s => s.versionID == 2).
                            Select(s => new { s.pdlFlag, s.worldPayFieldName, s.worldPayTableName, s.worldPayJoinFields, s.worldPayCondition, s.worldPayOrderBy, s.worldPayFieldDescription, s.paramID, s.effectiveBeginDate, s.effectiveEndDate, s.viperCondition, s.viperFieldName, s.viperTableName, s.charStartIndex, s.charLength }).ToList();

            var newTable = api.petroTable.Where(s => s.VersionID == 1)
                           .Select(s => new { s.SchemaDef, s.DefaultXML, s.Active, s.CreatedDate, s.DefinitionOnly, s.EffectiveDate, s.LastUpdatedBy, s.LastUpdatedDate, s.TableID, s.TableName }).ToList();
            var oldTable = api.petroTable.Where(s => s.VersionID == 2)
                           .Select(s => new { s.SchemaDef, s.DefaultXML, s.Active, s.CreatedDate, s.DefinitionOnly, s.EffectiveDate, s.LastUpdatedBy, s.LastUpdatedDate, s.TableID, s.TableName }).ToList();

            //..Assert
            Assert.Equal(((bool)actualRecord), true);
            Assert.Equal(fromMapping, toMapping);
            Assert.Equal(newTable, oldTable);
        }
Exemplo n.º 3
0
        public async Task RetrieveEPSMappingAsync_Success()
        {
            int id = 3;
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi       epsMappingApi      = new EPSMappingApi(appSettings, bApi);
            EPSMappingController controller         = FakeController(_cache, epsMappingApi);

            //.. Act
            var dinfo = await controller.Get(id);

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

            //..Assert
            Assert.Equal((List <EPSMapping>)(actualRecord), bApi.epsMapping.Where(s => s.versionID == 3).ToList());
        }
Exemplo n.º 4
0
        public async Task RetrieveEPSMappingAsync_Fail()
        {
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi epsMappingApi            = new EPSMappingApi(appSettings, bApi);
            var            localizer = new MockStringLocalizer <EPSMappingController>();

            localizer[0] = new LocalizedString("EPSMappingRetrieveErrorMsg", "Version id is not provided");
            EPSMappingController controller = FakeController(_cache, epsMappingApi, localizer);

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

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

            //..Assert
            Assert.Equal((actualRecord).StatusCode, 500);
            Assert.Equal(actualRecord.Value, "Version id is not provided");
        }
Exemplo n.º 5
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.º 6
0
        public async Task InsertEPSMappingTest_FailOnPdfFlagTrue()
        {
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi epsMappingApi            = new EPSMappingApi(appSettings, bApi);
            var            localizer = new MockStringLocalizer <EPSMappingController>();

            localizer[0] = new LocalizedString("EPSMappingParamNameErrorMsg", "ParamName is mandatory");

            EPSMappingController controller = FakeController(_cache, epsMappingApi, localizer);
            EPSMapping           epsMapping = new EPSMapping();

            epsMapping.versionID                = 1;
            epsMapping.pdlFlag                  = true;
            epsMapping.paramID                  = 200;
            epsMapping.worldPayFieldName        = null;
            epsMapping.worldPayTableName        = null;
            epsMapping.worldPayJoinFields       = null;
            epsMapping.worldPayCondition        = null;
            epsMapping.worldPayOrderBy          = null;
            epsMapping.worldPayFieldDescription = "Master Cutoff Amount1";
            epsMapping.effectiveBeginDate       = DateTime.Now;
            epsMapping.effectiveEndDate         = DateTime.Now;
            epsMapping.viperTableName           = "Fee";
            epsMapping.viperFieldName           = "/ Fee / FeeRow / FeeAmount";
            epsMapping.viperCondition           = null;
            epsMapping.charStartIndex           = 102;
            epsMapping.charLength               = 3;
            epsMapping.createdByUser            = "******";
            //.. Act
            var dinfo = await controller.Post(epsMapping);

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

            //..Assert
            Assert.Equal(actualRecord.StatusCode, (int)System.Net.HttpStatusCode.BadRequest);
            Assert.Equal(actualRecord.Value, "ParamName is mandatory");
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public async Task CopyEpsMappingAsync_ToVersionNotExistsFail()
        {
            IDistributedCache   _cache        = FakeCache();
            IOptions <Settings> appSettings   = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi      epsMappingApi = new EPSMappingApi(appSettings, new MockEPSMappingApiRepository());
            var localizer = new MockStringLocalizer <EPSMappingController>();

            localizer[0] = new LocalizedString("EPSMappingCopyErrorMsg", "Error occured while copying Mappings");

            EPSMappingController controller = FakeController(_cache, epsMappingApi, localizer);

            //.. Act
            var dinfo = await controller.Copy(new EPSCopyMapping()
            {
                FromVersionID = 1, ToVersionID = 6
            });

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

            //..Assert
            Assert.Equal((actualRecord.StatusCode), (int)System.Net.HttpStatusCode.InternalServerError);
            Assert.Equal((actualRecord.Value), "Error occured while copying Mappings");
        }