Ejemplo n.º 1
0
        public async Task CommanderVersionControllerTestCreateVersion_FailInvalidFormat()
        {
            MockCommanderVersionRepository api = new MockCommanderVersionRepository();
            IDistributedCache   _cache         = FakeCache();
            IOptions <Settings> appSettings    = Substitute.For <IOptions <Settings> >();
            var localizer = new MockStringLocalizer <CommanderVersionController>();

            localizer[0] = new LocalizedString("CommanderCreateversionsVersionFormatErrorMsg", "Invalid Version format");
            ICommanderVersionApi       commanderVersionApi = new CommanderVersionApi(appSettings, api);
            CommanderVersionController controller          = FakeController(_cache, commanderVersionApi, localizer);

            Wp.CIS.LynkSystems.Model.CommanderVersion commanderVersion = new Wp.CIS.LynkSystems.Model.CommanderVersion()
            {
                BaseVersionID      = null,
                VersionDescription = "test 123"
            };
            //.. Act

            var dinfo = await controller.CreateVersion(commanderVersion);

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

            //..Assert
            Assert.Equal(actualRecord.StatusCode, (int)System.Net.HttpStatusCode.BadRequest);
            Assert.Equal(actualRecord.Value, "Invalid Version format");
        }
Ejemplo n.º 2
0
        public async Task CommanderVersionControllerTestCreateVersion_BaseVersionFail()
        {
            MockCommanderVersionRepository api = new MockCommanderVersionRepository();
            IDistributedCache   _cache         = FakeCache();
            IOptions <Settings> appSettings    = Substitute.For <IOptions <Settings> >();

            var localizer = new MockStringLocalizer <CommanderVersionController>();

            localizer[0] = new LocalizedString("CommanderCreateversionsErrorMsg", "Base version not exists");
            ICommanderVersionApi       commanderVersionApi = new CommanderVersionApi(appSettings, api);
            CommanderVersionController controller          = FakeController(_cache, commanderVersionApi, localizer);


            Wp.CIS.LynkSystems.Model.CommanderVersion commanderVersion = new Wp.CIS.LynkSystems.Model.CommanderVersion()
            {
                BaseVersionID      = 1000,
                VersionDescription = "WPYPAK 6.02.08",
                CreatedByUser      = "******"
            };
            //.. Act

            var dinfo = await controller.CreateVersion(commanderVersion);

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

            //..Assert
            Assert.Equal(actualRecord.StatusCode, (int)System.Net.HttpStatusCode.InternalServerError);
            Assert.Equal((actualRecord.Value), "Base version not exists");
        }
Ejemplo n.º 3
0
        public async Task CommanderVersionControllerTestCreateVersion_Pattern2Success()
        {
            MockCommanderVersionRepository api             = new MockCommanderVersionRepository();
            IDistributedCache          _cache              = FakeCache();
            IOptions <Settings>        appSettings         = Substitute.For <IOptions <Settings> >();
            ICommanderVersionApi       commanderVersionApi = new CommanderVersionApi(appSettings, api);
            CommanderVersionController controller          = FakeController(_cache, commanderVersionApi);

            Wp.CIS.LynkSystems.Model.CommanderVersion commanderVersion = new Wp.CIS.LynkSystems.Model.CommanderVersion()
            {
                BaseVersionID      = null,
                VersionDescription = "WPYPAK 6.02.06",
                CreatedByUser      = "******"
            };
            //.. Act

            var dinfo = await controller.CreateVersion(commanderVersion);

            var actualRecord   = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;
            int newVersionId   = api.versionInfo.Max(s => Convert.ToInt32(s.VersionID));
            var currentVersion = api.versionInfo.Where(s => Convert.ToInt32(s.VersionID) == newVersionId).FirstOrDefault();

            //..Assert
            Assert.Equal(((bool)actualRecord), true);
            Assert.Equal(commanderVersion, currentVersion);
        }
Ejemplo n.º 4
0
        public async Task CommanderVersionControllerTestCreateVersion_BaseVersionSuccess()
        {
            MockCommanderVersionRepository api             = new MockCommanderVersionRepository();
            IDistributedCache          _cache              = FakeCache();
            IOptions <Settings>        appSettings         = Substitute.For <IOptions <Settings> >();
            ICommanderVersionApi       commanderVersionApi = new CommanderVersionApi(appSettings, api);
            CommanderVersionController controller          = FakeController(_cache, commanderVersionApi);

            int baseversionId = 1;

            Wp.CIS.LynkSystems.Model.CommanderVersion commanderVersion = new Wp.CIS.LynkSystems.Model.CommanderVersion()
            {
                BaseVersionID      = baseversionId,
                VersionDescription = "WPYPAK 6.02.07",
                CreatedByUser      = "******"
            };

            //.. Act

            var dinfo = await controller.CreateVersion(commanderVersion);

            var actualRecord      = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;
            int newVersionId      = api.versionInfo.Max(s => Convert.ToInt32(s.VersionID));
            var newVersionMapping = api.epsMapping.Where(s => s.versionID == newVersionId).
                                    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 oldVersionMapping = api.epsMapping.Where(s => s.versionID == baseversionId).
                                    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 == newVersionId)
                           .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 == baseversionId)
                           .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 currentVersion = api.versionInfo.Where(s => Convert.ToInt32(s.VersionID) == newVersionId).FirstOrDefault();

            //..Assert
            Assert.Equal(((bool)actualRecord), true);
            Assert.Equal(currentVersion, commanderVersion);
            Assert.Equal(newVersionMapping, oldVersionMapping);
            Assert.Equal(newTable, oldTable);
        }