Exemplo n.º 1
0
        public void TestValidSingleSearch1OptionField(string fieldName, string condition)
        {
            condition = condition.ToLowerString();

            string conditionValue1 = PhaseHelper.GetValueField(defaultResource, records.Data[$"{defaultResource.ToPrivateEnum()}{num}"].Records.Id.ToString(), new List <string> {
                fieldName
            }).Select(item => (item.PhaseObject as Option).ActualXMLTag).ToList().Random();
            string conditionValue2 = PhaseHelper.GetValueField(defaultResource, records.Data[$"{defaultResource.ToPrivateEnum()}{num}"].Records.Id.ToString(), new List <string> {
                fieldName
            }).Select(item => (item.PhaseObject as Option).ActualXMLTag).ToList().Random();

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)defaultResource },
                { PhaseApiFields.Condition, $"{fieldName}:{condition}={conditionValue1}:{conditionValue2}" },
                { PhaseApiFields.Field, fieldName },
            };

            ReadResponseData <Phase> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Phase>(parameters);

            Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), string.Format(Enums.Message.READ_RESOURCE_FAILED, nameof(Phase)));

            foreach (var item in result.Items)
            {
                Assert.That((item.DictionaryValues[fieldName] as Option).ActualXMLTag, PhaseHelper.OptionConditionsMap[condition](conditionValue1, conditionValue2), DateTimeValidator.ErrorMessage);
            }
        }
Exemplo n.º 2
0
 public TestDeleteRecordContainsPhase()
 {
     foreach (var resourceId in Enum.GetValues(typeof(Enums.ResourceType)).Cast <Enums.ResourceType>().Where(r => r != Enums.ResourceType.Contract))
     {
         optionIds.Add(resourceId, PhaseHelper.GetLastPhaseOptionId(resourceId));
     }
 }
Exemplo n.º 3
0
        public static void Postfix(Vehicle __instance)
        {
            int initPhase = PhaseHelper.TonnageToPhase((int)Math.Ceiling(__instance.tonnage));

            Mod.Log.Debug?.Write($"Setting baseInit for vehicle: {CombatantUtils.Label(__instance)} to {initPhase}");
            __instance.StatCollection.Set <int>(ModStats.BaseInitiative, initPhase);
        }
Exemplo n.º 4
0
 public DungeonBuilder(string world, string meshDir)
 {
     Dungeon  = world;
     _meshDir = meshDir;
     Config   = RecastConfig.Dungeon;
     MapId    = PhaseHelper.GetMapIdByName(Dungeon);
 }
Exemplo n.º 5
0
        public void TestSearchMultipleOrderField(string fieldName1, string condition1, string fieldName2, string condition2, string orderType)
        {
            Dictionary <string, Type> sortOrders = new Dictionary <string, Type>();
            string idField = "Id";

            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)defaultResource },
            };

            //List of sort order class { <field, sortType, Type>, <field, sortType, Type>,... }
            List <SortOrders> sortOrderFieldList = new List <SortOrders>()
            {
                { new SortOrders(fieldName1, condition1, SearchTestData.phaseFieldList[fieldName1]) },
                { new SortOrders(fieldName2, condition2, SearchTestData.phaseFieldList[fieldName2]) },
            };

            SortOrders parameterSortOrder = PhaseHelper.GetParameterSortOrders(sortOrderFieldList, idField, orderType);

            urlParameters[PhaseApiFields.Order] = parameterSortOrder.Condition;
            urlParameters[PhaseApiFields.Field] = parameterSortOrder.Field;
            sortOrders = parameterSortOrder.SortOrderTypes;

            //Sort
            List <XmlResource> result      = ReadPhaseResource(urlParameters);
            List <XmlResource> sortedItems = ResourceHelper.SortList(result, sortOrders);

            Assert.IsTrue(ResourceHelper.CompareList(result, sortedItems, idField), Enums.Message.SORT_INCORRECT);
        }
        private Phase CreateBulkWritePhaseInstance(Enums.ResourceType resourceType, BulkWriteInputType itemType, int index = 0)
        {
            Phase result = null;

            switch (itemType)
            {
            case BulkWriteInputType.ValidItem:
                result = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, index);
                break;

            case BulkWriteInputType.InvalidItem:
                result = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, index);
                result.DictionaryValues["Datexxx"] = "Abc";
                break;

            case BulkWriteInputType.UpdatedItem:
                result = new Phase()
                {
                    Id   = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{index}"].FirstOrDefault().Id,
                    Date = Util.ToString(DateTime.Now, false),
                };
                break;

            case BulkWriteInputType.CreatedItem:
                result = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, index);
                break;
            }
            return(result);
        }
Exemplo n.º 7
0
        public void TestReadPhaseWithDuplicateParameters(string param, bool isDuplicatedValue)
        {
            Enums.ResourceType          job        = Enums.ResourceType.Job;
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
            };

            List <object> duplicatedParameters = new List <object>();

            var parameterValues = new Dictionary <string, object>
            {
                [PhaseApiFields.ResourceId + "1"] = (int)records.Data[$"{job.ToPrivateEnum()}0"].Id,
                [PhaseApiFields.ResourceId + "2"] = (int)records.Data[$"{job.ToPrivateEnum()}1"].Id,
                [PhaseApiFields.Id + "1"]         = PhaseHelper.CreatePhase(job, records.Data[$"{job.ToPrivateEnum()}0"].Id.ToString()),
                [PhaseApiFields.Id + "2"]         = PhaseHelper.CreatePhase(job, records.Data[$"{job.ToPrivateEnum()}1"].Id.ToString()),
                [PhaseApiFields.Resource + "1"]   = (int)Enums.ResourceType.Client,
                [PhaseApiFields.Resource + "2"]   = (int)Enums.ResourceType.Activity,
                [PhaseApiFields.Count + "1"]      = 10,
                [PhaseApiFields.Count + "2"]      = 11,
                [PhaseApiFields.Start + "1"]      = 10,
                [PhaseApiFields.Start + "2"]      = 12,
                [PhaseApiFields.Field + "1"]      = PhaseApiFields.Memo,
                [PhaseApiFields.Field + "2"]      = PhaseApiFields.Phase,
                [PhaseApiFields.Condition + "1"]  = $"{nameof(PhaseApiFields.Id)}:eq={records.Data[$"{job.ToPrivateEnum()}0"].Id}",
                [PhaseApiFields.Condition + "2"]  = $"{nameof(PhaseApiFields.Id)}:eq={records.Data[$"{job.ToPrivateEnum()}1"].Id}",
                [PhaseApiFields.Order + "1"]      = $"{PhaseApiFields.Order}={nameof(PhaseApiFields.Id)}:{records.Data[$"{job.ToPrivateEnum()}0"].Id}",
                [PhaseApiFields.Order + "2"]      = $"{PhaseApiFields.Order}={nameof(PhaseApiFields.Id)}:{records.Data[$"{job.ToPrivateEnum()}1"].Id}",
            };

            if (isDuplicatedValue)
            {
                duplicatedParameters = new List <object>
                {
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}1"],
                };
            }
            else
            {
                duplicatedParameters = new List <object>
                {
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}2"],
                    parameterValues[$"{param}2"],
                };
            }

            if (param != PhaseApiFields.Resource)
            {
                parameters.Add(PhaseApiFields.Resource, (int)job);
            }
            parameters.Add(param, duplicatedParameters);

            ErrorCode result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail <Phase>(parameters);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE);
        }
 public TestMultipleSearchMultipleField()
 {
     //Create 16 phase entries
     for (int i = 1; i <= 4; i++)
     {
         PhaseHelper.CreatePhaseWithGenerateSystemDateTimeField(); //Create 4 phase entries
     }
 }
Exemplo n.º 9
0
 public TileBuilder(string world, int x, int y)
 {
     World  = world;
     X      = x;
     Y      = y;
     Config = RecastConfig.Default;
     MapId  = PhaseHelper.GetMapIdByName(World);
 }
Exemplo n.º 10
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType)
        {
            Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType);

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 11
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, WriteInvalidMemoInput valueType, int expectedCode)
        {
            var phase = UpdateSinglePhaseInstance(resourceType, valueType);
            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(error.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestUpdateListItem(string fieldName, WriteInvalidResourceInput valueType, int expectedCode)
        {
            var error = PhaseHelper.WritePhasesFail(new List <Phase> {
                UpdateSinglePhaseInstance(fieldName, valueType, 0), UpdateSinglePhaseInstance(fieldName, valueType, 1)
            });

            Assert.That(error, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, defaultResource));
            Assert.That(error.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 13
0
        public TestMultipleSearch1Field()
        {
            //Create 4 phase entries by public
            PhaseHelper.CreatePhaseWithGenerateSystemDateTimeField();

            //Create 5 phase entries more by private. Make sure that we have multiple phase entry to search correctly
            recordUpdater1 = new HrbcRecordUpdater(() => PhaseHelper.InitRecordsUpdater(records, defaultResource, indexHrbcRecord, 1)); //Update phase in middle. Note: should choose resource type more than 3 option phases
            recordUpdater2 = new HrbcRecordUpdater(() => PhaseHelper.InitRecordsUpdater(records, defaultResource, indexHrbcRecord, 2));
            recordUpdater3 = new HrbcRecordUpdater(() => PhaseHelper.InitRecordsUpdater(records, defaultResource, indexHrbcRecord, 3));
        }
Exemplo n.º 14
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType);

            phase.Memo = Util.GetRandomText(textType, stringLength[lengthType]);

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 15
0
        public void TestCreateListItem(Enums.ResourceType resourceType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                return(PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey));
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 16
0
        public static void Postfix(Mech __instance)
        {
            int initPhase = PhaseHelper.TonnageToPhase((int)Math.Ceiling(__instance.tonnage));

            Mod.Log.Debug?.Write($"Setting baseInit for mech: {CombatantUtils.Label(__instance)} to {initPhase}");

            // We have to remove the stat, then set it to the default value we want. We do this because when the history is reverted (from effect expiriation)
            //   it reverts to the value initally set on the statistic
            __instance.StatCollection.RemoveStatistic(ModStats.BaseInitiative);
            __instance.StatCollection.AddStatistic <int>(ModStats.BaseInitiative, initPhase);
        }
Exemplo n.º 17
0
        public void TestCreateSingleItem(ResourceType resourceType, string fieldName, string fieldValue, int expectedCode)
        {
            Phase phase = PhaseHelper.CreatePhaseInstance(records, resourceType);

            phase.DictionaryValues[fieldName] = fieldValue;

            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(error.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 18
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string fieldValue = FieldValueMapper.ValidInputMapper[valueType];

            Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType);

            phase.DictionaryValues[fieldName] = fieldValue;

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 19
0
        private string GetPhaseValueText(ModelRiskAlert alert)
        {
            StringBuilder returnText = new StringBuilder();
            List <ModelRiskAlertPhase> modelRiskAlertPhases = ModelRiskAlertHelper.GetPhases(alert);

            foreach (var modelRiskAlertPhase in modelRiskAlertPhases)
            {
                Phase phase = PhaseHelper.Get(modelRiskAlertPhase.IDPhase);
                returnText.Append(phase.Title + "<br/>");
            }
            return(returnText.ToString());
        }
Exemplo n.º 20
0
        public void TestUpdateSingleItem(ResourceType resourceType, string fieldName, string fieldValue, int expectedCode)
        {
            var phase = new Phase {
                Id = phaseEntryReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].First().Id
            };

            phase.DictionaryValues[fieldName] = fieldValue;

            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 21
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var phase = new Phase
            {
                Id   = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].FirstOrDefault().Id,
                Memo = Util.GetRandomText(textType, stringLength[lengthType]),
            };

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot update phase memo for {0}", resourceType));
        }
        public void TestCreateSingleItem(Enums.ResourceType resourceType, InvalidPhaseOption valueType, int expectedCode)
        {
            object fieldValue = GetOptionValue(valueType, resourceType);

            Phase phase = PhaseHelper.CreatePhaseInstance(creatingRecords, resourceType);

            phase.PhaseObject = fieldValue;

            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(error.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 23
0
        public void TestCreateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey);
                phase.Memo  = Util.GetRandomText(textType, stringLength[lengthType]);
                return(phase);
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 24
0
        private Phase CreateSinglePhaseInstance(Enums.ResourceType resourceType, WriteInvalidMemoInput valueType, int index = 0)
        {
            string fieldValue = Util.GetRandomText(Enums.TextType.BasicLatin, overMaxLen);
            Phase  phase      = PhaseHelper.CreatePhaseInstance(recordsWithPhase, resourceType, index);

            if (valueType == WriteInvalidMemoInput.MemoWithoutPhase)
            {
                phase.DictionaryValues.Remove(PhaseApiFields.Phase);
                fieldValue = Util.GetRandomText(Enums.TextType.BasicLatin, 1000);
            }
            phase.Memo = fieldValue;

            return(phase);
        }
Exemplo n.º 25
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, string fieldName, WriteInvalidInput valueType, int expectedCode)
        {
            string fieldValue = FieldValueMapper.InvalidMapper[valueType];

            var phase = new Phase {
                Id = ReadPhaseBasedOnResource(resourceType, 0)
            };

            phase.DictionaryValues[fieldName] = fieldValue;

            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, InvalidPhaseOption valueType, int expectedCode)
        {
            object fieldValue = GetOptionValue(valueType, resourceType);

            var phase = new Phase {
                Id = ReadPhaseBasedOnResource(resourceType, 0), Date = Util.ToString(DateTime.Now)
            };

            phase.PhaseObject = fieldValue;

            var error = PhaseHelper.WritePhaseFail(phase);

            Assert.That(error, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 27
0
        public void TestUpdateListItem(ResourceType resourceType, string fieldName, string fieldValue, int expectedCode)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = new Phase {
                    Id = phaseEntryReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].First().Id
                };
                phase.DictionaryValues[fieldName] = fieldValue;
                return(phase);
            });

            ErrorCode result = PhaseHelper.WritePhasesFail(resourceList);

            Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 28
0
        public void TestCreateListItem(ResourceType resourceType, string fieldName, string fieldValue, int expectedCode)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = PhaseHelper.CreatePhaseInstance(records, resourceType, depKey);
                phase.DictionaryValues[fieldName] = fieldValue;

                return(phase);
            }).ToList();

            ErrorCode result = PhaseHelper.WritePhasesFail(resourceList);

            Assert.That(result, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(result.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Exemplo n.º 29
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string fieldValue = FieldValueMapper.ValidInputMapper[valueType];

            var phase = new Phase
            {
                Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].FirstOrDefault().Id,
            };

            phase.DictionaryValues[fieldName] = fieldValue;

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }
Exemplo n.º 30
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType)
        {
            var resourcePhase = PhaseSearcher.Data.Options.Where(op => op.Alias == $"Option.P_{resourceType.ToResourceName()}Phase").SingleOrDefault();
            var phase         = new Phase
            {
                Id          = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].FirstOrDefault().Id,
                PhaseObject = new Option()
                {
                    ActualXMLTag = resourcePhase.Children.FirstOrDefault().Alias
                },
            };

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }