コード例 #1
0
ファイル: Program.cs プロジェクト: Savidiy/homework
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Clear();
                int sizeX    = 10;
                int sizeY    = 3;
                int minValue = -100;
                int maxValue = 100;
                PrintLn($"Создaем массив размером {sizeX} на {sizeY}, заполненный случайными числами от {minValue} до {maxValue}:");
                TwoDimArray arrayRnd = new TwoDimArray(sizeX, sizeY, minValue, maxValue);
                arrayRnd.GetIndexOfMax(out int indexMaxX, out int indexMaxY);
                for (int y = 0; y < sizeY; y++)
                {
                    for (int x = 0; x < sizeX; x++)
                    {
                        if (x == indexMaxX && y == indexMaxY)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Print(String.Format("{0,4:0.#}", arrayRnd[x, y]) + " ");
                            Console.ForegroundColor = ConsoleColor.Gray;
                        }
                        else
                        {
                            Print(String.Format("{0,4:0.#}", arrayRnd[x, y]) + " ");
                        }
                    }
                    PrintLn();
                }
                PrintLn($"Самое большое число в массиве {arrayRnd.Max} расположено в координатах [{indexMaxX},{indexMaxY}].");
                PrintLn($"Самое маленькое число в массиве {arrayRnd.Min}.");
                PrintLn($"Сумма всех элементов массива равна {arrayRnd.GetSum()}.");
                int border = 90;
                PrintLn($"Сумма всех элементов массива больше {border} равна {arrayRnd.GetSumOver(border)}.");
                string outputFileName = "ArrayOutput.txt";
                PrintLn($"Попробуем сохранить массив в файл {outputFileName}.");
                arrayRnd.SaveToFile(outputFileName);
                PrintLn($"Попробуем загрузить массив обратно из файла {outputFileName}.");
                arrayRnd = new TwoDimArray(outputFileName);
                PrintLn();
                PrintLn($"Попробуем сохранить массив в файл без имени:");
                arrayRnd.SaveToFile("");

                PrintLn();
                string inputFileName = "ArrayInput.txt";
                PrintLn($"Попробуем загрузить массив из файла {inputFileName}:");
                TwoDimArray arrayFromFile = new TwoDimArray(inputFileName);
                for (int y = 0; y < arrayFromFile.SizeY; y++)
                {
                    for (int x = 0; x < arrayFromFile.SizeX; x++)
                    {
                        Print(String.Format("{0,4:0.#}", arrayFromFile[x, y]) + " ");
                    }
                    PrintLn();
                }

                Print("\nНажмите любую клавишу для повтора");
                Console.ReadKey();
            }
        }
コード例 #2
0
        public void Custom2daReturnsValidValues()
        {
            string twoDimArray =
                @"2DA V2.0

    LABEL    TESTSTR      TESTINT          TESTFLOAT
0   Test0    ""Test 0""   0                0.0f 
1   Test1    ""Test 1""   0x1              1.0f
2   Test2    ""Test 2""   0x00000002       2.0f";

            string resourceName = "testtemp.2da";

            ResourceManager.WriteTempResource(resourceName, StringHelper.Cp1252Encoding.GetBytes(twoDimArray));
            createdTempResources.Add(resourceName);

            TwoDimArray array = NwGameTables.GetTable(resourceName);

            Assert.That(array.RowCount, Is.EqualTo(3));
            Assert.That(array.ColumnCount, Is.EqualTo(4));
            Assert.That(array.Columns, Is.EquivalentTo(new[] { "label", "teststr", "testint", "testfloat" }));

            Assert.That(array.GetString(0, "TESTSTR"), Is.EqualTo("Test 0"));
            Assert.That(array.GetString(1, "TESTSTR"), Is.EqualTo("Test 1"));
            Assert.That(array.GetString(2, "TESTSTR"), Is.EqualTo("Test 2"));
            Assert.That(array.GetInt(0, "TESTINT"), Is.EqualTo(0));
            Assert.That(array.GetInt(1, "TESTINT"), Is.EqualTo(0x1));
            Assert.That(array.GetInt(2, "TESTINT"), Is.EqualTo(0x00000002));
            Assert.That(array.GetFloat(0, "TESTFLOAT"), Is.EqualTo(0f));
            Assert.That(array.GetFloat(1, "TESTFLOAT"), Is.EqualTo(1f));
            Assert.That(array.GetFloat(2, "TESTFLOAT"), Is.EqualTo(2f));
        }
コード例 #3
0
 public void Invalid2daThrowsException()
 {
     Assert.That(() =>
     {
         TwoDimArray _ = NwGameTables.GetTable("invalidtest");
     }, Throws.Exception.TypeOf <ArgumentException>());
 }
コード例 #4
0
        public void Same2daMixedIsConsideredEqual()
        {
            TwoDimArray array1 = NwGameTables.GetTable("appearance.2da");
            TwoDimArray <AppearanceTableEntry> array2 = NwGameTables.GetTable <AppearanceTableEntry>("appearance.2da");

            Assert.That(array1, Is.EqualTo(array2));
        }
コード例 #5
0
        public void Different2daAreNotConsideredEqual()
        {
            TwoDimArray array1 = NwGameTables.GetTable <AppearanceTableEntry>("appearance.2da");
            TwoDimArray array2 = NwGameTables.GetTable <EnvironmentPreset>("environment.2da");

            Assert.That(array1, Is.Not.EqualTo(array2));
        }
コード例 #6
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void DamageLevelTableReturnsValidData(int rowIndex, string label, int?strRef)
        {
            TwoDimArray <DamageLevelEntry> table = NwGameTables.DamageLevelTable;
            DamageLevelEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.StrRef?.Id, Is.EqualTo(strRef));
        }
コード例 #7
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void ExpTableReturnsValidData(int rowIndex, int?level, uint?xp)
        {
            TwoDimArray <ExpTableEntry> table = NwGameTables.ExpTable;
            ExpTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Level, Is.EqualTo(level));
            Assert.That(row.XP, Is.EqualTo(xp));
        }
コード例 #8
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void PartsTableReturnsValidData(int rowIndex, int?costModifier, float?acBonus, int?armorTableEntry)
        {
            TwoDimArray <PartsTableEntry> table = NwGameTables.PartsChestTable;
            PartsTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.CostModifier, Is.EqualTo(costModifier));
            Assert.That(row.ACBonus, Is.EqualTo(acBonus));
            Assert.That(row.ArmorTableEntry?.RowIndex, Is.EqualTo(armorTableEntry));
        }
コード例 #9
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void BodyBagTableReturnsValidData(int rowIndex, string label, uint?nameStrRef, int?appearance)
        {
            TwoDimArray <BodyBagTableEntry> table = NwGameTables.BodyBagTable;
            BodyBagTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.Name?.Id, Is.EqualTo(nameStrRef));
            Assert.That(row.Appearance?.RowIndex, Is.EqualTo(appearance));
        }
コード例 #10
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void SkillItemCostTableReturnsValidData(int rowIndex, int?deviceCostMax, int?skillReqClass, int?skillReqRace, int?skillReqAlign)
        {
            TwoDimArray <SkillItemCostTableEntry> table = NwGameTables.SkillItemCostTable;
            SkillItemCostTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.DeviceCostMax, Is.EqualTo(deviceCostMax));
            Assert.That(row.ClassSkillRequirement, Is.EqualTo(skillReqClass));
            Assert.That(row.RaceSkillRequirement, Is.EqualTo(skillReqRace));
            Assert.That(row.AlignmentSkillRequirement, Is.EqualTo(skillReqAlign));
        }
コード例 #11
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void LightColorTableReturnsValidData(int rowIndex, float red, float green, float blue, string label, float toolsetRed, float toolsetGreen, float toolsetBlue)
        {
            TwoDimArray <LightColorTableEntry> table = NwGameTables.LightColorTable;
            LightColorTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Red, Is.EqualTo(red));
            Assert.That(row.Green, Is.EqualTo(green));
            Assert.That(row.Blue, Is.EqualTo(blue));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.ToolsetRed, Is.EqualTo(toolsetRed));
            Assert.That(row.ToolsetGreen, Is.EqualTo(toolsetGreen));
            Assert.That(row.ToolsetBlue, Is.EqualTo(toolsetBlue));
        }
コード例 #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Data Structures Program");

            ArrayNum obj = new ArrayNum();

            obj.AccessList();
            AccessStudents();
            TwoDimArray obj2 = new TwoDimArray();

            obj2.Access2DArray();

            Console.ReadLine();
        }
コード例 #13
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void PlaceableSoundTableReturnsValidData(int rowIndex, string label, string armorType, string opened, string closed, string destroyed, string used, string locked)
        {
            TwoDimArray <PlaceableSoundTableEntry> table = NwGameTables.PlaceableSoundTable;
            PlaceableSoundTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.ArmorType, Is.EqualTo(armorType));
            Assert.That(row.Opened, Is.EqualTo(opened));
            Assert.That(row.Closed, Is.EqualTo(closed));
            Assert.That(row.Destroyed, Is.EqualTo(destroyed));
            Assert.That(row.Used, Is.EqualTo(used));
            Assert.That(row.Locked, Is.EqualTo(locked));
        }
コード例 #14
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void ArmorTableReturnsValidData(int rowIndex, int?acBonus, int?dexBonus, int?acCheck, int?arcaneFailurePct, int?weight, int?cost, int?descriptionStrRef, int?baseItemStatsStrRef)
        {
            TwoDimArray <ArmorTableEntry> table = NwGameTables.ArmorTable;
            ArmorTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.ACBonus, Is.EqualTo(acBonus));
            Assert.That(row.DexBonus, Is.EqualTo(dexBonus));
            Assert.That(row.ACCheck, Is.EqualTo(acCheck));
            Assert.That(row.ArcaneFailurePct, Is.EqualTo(arcaneFailurePct));
            Assert.That(row.Weight, Is.EqualTo(weight));
            Assert.That(row.Cost, Is.EqualTo(cost));
            Assert.That(row.Description?.Id, Is.EqualTo(descriptionStrRef));
            Assert.That(row.BaseItemStats?.Id, Is.EqualTo(baseItemStatsStrRef));
        }
コード例 #15
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void AppearanceTableReturnsValidData(int rowIndex, string label, uint?strRef, string name, string race, string envMap,
                                                    string bloodColor, string modelType, float?weaponScale, float?wingTailScale, float?helmetScaleM, float?helmetScaleF, string moveRate,
                                                    float?walkDist, float?runDist, float?perSpace, float?crePerSpace, float?height, float?hitDist, float?prefAttackDist, string targetHeight,
                                                    bool?abortOnParry, int?racialType, bool?hasLegs, bool?hasArms, string portrait, int?sizeCategory, int?perceptionDist, int?footstepType,
                                                    int?soundAppType, bool?headTrack, int?headArcH, int?headArcV, string headName, int?bodyBag, bool?targetable)
        {
            TwoDimArray <AppearanceTableEntry> table = NwGameTables.AppearanceTable;
            AppearanceTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.StrRef?.Id, Is.EqualTo(strRef));
            Assert.That(row.Name, Is.EqualTo(name));
            Assert.That(row.Race, Is.EqualTo(race));
            Assert.That(row.EnvironmentMap, Is.EqualTo(envMap));
            Assert.That(row.BloodColor, Is.EqualTo(bloodColor));
            Assert.That(row.ModelType, Is.EqualTo(modelType));
            Assert.That(row.WeaponScale, Is.EqualTo(weaponScale));
            Assert.That(row.WingTailScale, Is.EqualTo(wingTailScale));
            Assert.That(row.HelmetScaleM, Is.EqualTo(helmetScaleM));
            Assert.That(row.HelmetScaleF, Is.EqualTo(helmetScaleF));
            Assert.That(row.MovementRate, Is.EqualTo(moveRate));
            Assert.That(row.WalkDistance, Is.EqualTo(walkDist));
            Assert.That(row.RunDistance, Is.EqualTo(runDist));
            Assert.That(row.PersonalSpace, Is.EqualTo(perSpace));
            Assert.That(row.CreaturePersonalSpace, Is.EqualTo(crePerSpace));
            Assert.That(row.Height, Is.EqualTo(height));
            Assert.That(row.HitDistance, Is.EqualTo(hitDist));
            Assert.That(row.PreferredAttackDistance, Is.EqualTo(prefAttackDist));
            Assert.That(row.TargetHeight, Is.EqualTo(targetHeight));
            Assert.That(row.AbortOnParry, Is.EqualTo(abortOnParry));
            Assert.That(row.RacialType, Is.EqualTo(racialType));
            Assert.That(row.HasLegs, Is.EqualTo(hasLegs));
            Assert.That(row.HasArms, Is.EqualTo(hasArms));
            Assert.That(row.Portrait, Is.EqualTo(portrait));
            Assert.That(row.SizeCategory, Is.EqualTo(sizeCategory));
            Assert.That(row.PerceptionDistance, Is.EqualTo(perceptionDist));
            Assert.That(row.FootstepType, Is.EqualTo(footstepType));
            Assert.That(row.AppearanceSoundSet, Is.EqualTo(soundAppType));
            Assert.That(row.HeadTrack, Is.EqualTo(headTrack));
            Assert.That(row.HeadArcHorizontal, Is.EqualTo(headArcH));
            Assert.That(row.HeadArcVertical, Is.EqualTo(headArcV));
            Assert.That(row.HeadName, Is.EqualTo(headName));
            Assert.That(row.BodyBag?.RowIndex, Is.EqualTo(bodyBag));
            Assert.That(row.Targetable, Is.EqualTo(targetable));
        }
コード例 #16
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void ProgrammedEffectTableReturnsValidData()
        {
            TwoDimArray <ProgrammedEffectTableEntry> table = NwGameTables.ProgrammedEffectTable;

            ProgrammedEffectTableEntry envMapRow = table.GetRow(100);

            Assert.That(envMapRow.RowIndex, Is.EqualTo(100));
            Assert.That(envMapRow.Label, Is.EqualTo("EnvMap00"));
            Assert.That(envMapRow.Type, Is.EqualTo(ProgFxType.EnvironmentMap));
            Assert.That(envMapRow.GetParamString(1), Is.EqualTo("vdu_envmap_000"));
            Assert.That(envMapRow.GetParamString(2), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(3), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(4), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(5), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(6), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(7), Is.EqualTo(null));
            Assert.That(envMapRow.GetParamString(8), Is.EqualTo(null));

            ProgrammedEffectTableEntry selfIllumRow = table.GetRow(200);

            Assert.That(selfIllumRow.RowIndex, Is.EqualTo(200));
            Assert.That(selfIllumRow.Label, Is.EqualTo("SelfIllumRed"));
            Assert.That(selfIllumRow.Type, Is.EqualTo(ProgFxType.StaticGlow));
            Assert.That(selfIllumRow.GetParamFloat(1), Is.EqualTo(1.0f));
            Assert.That(selfIllumRow.GetParamFloat(2), Is.EqualTo(0.0f));
            Assert.That(selfIllumRow.GetParamFloat(3), Is.EqualTo(0.0f));
            Assert.That(selfIllumRow.GetParamFloat(4), Is.EqualTo(null));
            Assert.That(selfIllumRow.GetParamFloat(5), Is.EqualTo(null));
            Assert.That(selfIllumRow.GetParamFloat(6), Is.EqualTo(null));
            Assert.That(selfIllumRow.GetParamFloat(7), Is.EqualTo(null));
            Assert.That(selfIllumRow.GetParamFloat(8), Is.EqualTo(null));

            ProgrammedEffectTableEntry lightRow = table.GetRow(300);

            Assert.That(lightRow.RowIndex, Is.EqualTo(300));
            Assert.That(lightRow.Label, Is.EqualTo("LightWhite5m"));
            Assert.That(lightRow.Type, Is.EqualTo(ProgFxType.Light));
            Assert.That(lightRow.GetParamString(1), Is.EqualTo("White_5m"));
            Assert.That(lightRow.GetParamFloat(2), Is.EqualTo(1.0f));
            Assert.That(lightRow.GetParamInt(3), Is.EqualTo(0));
            Assert.That(lightRow.GetParamInt(4), Is.EqualTo(20));
            Assert.That(lightRow.GetParamInt(5), Is.EqualTo(0));
            Assert.That(lightRow.GetParamInt(6), Is.EqualTo(0));
            Assert.That(lightRow.GetParamString(7), Is.EqualTo("fx_light_clr"));
            Assert.That(lightRow.GetParamString(8), Is.EqualTo(null));
        }
コード例 #17
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void EnvironmentTableReturnsValidData(int rowIndex, string label, uint strRef, DayNightMode dayNight, byte lightAmbRed,
                                                     byte lightAmbGreen, byte lightAmbBlue, byte lightDiffRed, byte lightDiffGreen, byte lightDiffBlue, bool lightShadows,
                                                     byte darkAmbRed, byte darkAmbGreen, byte darkAmbBlue, byte darkDiffRed, byte darkDiffGreen, byte darkDiffBlue, bool darkShadows,
                                                     byte lightFogRed, byte lightFogGreen, byte lightFogBlue, byte darkFogRed, byte darkFogGreen, byte darkFogBlue, byte lightFog, byte darkFog,
                                                     int main1Color1, int main1Color2, int main1Color3, int main1Color4, int main2Color1, int main2Color2, int main2Color3, int main2Color4,
                                                     int secondaryColor1, int secondaryColor2, int secondaryColor3, int secondaryColor4, byte wind, byte snow, byte rain, byte lightning, float shadowAlpha)
        {
            TwoDimArray <EnvironmentPreset> table = NwGameTables.EnvironmentPresetTable;
            EnvironmentPreset row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.StrRef, Is.EqualTo(new StrRef(strRef)));
            Assert.That(row.DayNightMode, Is.EqualTo(dayNight));
            Assert.That(row.SunAmbientColor, Is.EqualTo(new Color(lightAmbRed, lightAmbGreen, lightAmbBlue)));
            Assert.That(row.SunDiffuseColor, Is.EqualTo(new Color(lightDiffRed, lightDiffGreen, lightDiffBlue)));
            Assert.That(row.SunShadows, Is.EqualTo(lightShadows));
            Assert.That(row.MoonAmbientColor, Is.EqualTo(new Color(darkAmbRed, darkAmbGreen, darkAmbBlue)));
            Assert.That(row.MoonDiffuseColor, Is.EqualTo(new Color(darkDiffRed, darkDiffGreen, darkDiffBlue)));
            Assert.That(row.MoonShadows, Is.EqualTo(darkShadows));
            Assert.That(row.SunFogColor, Is.EqualTo(new Color(lightFogRed, lightFogGreen, lightFogBlue)));
            Assert.That(row.MoonFogColor, Is.EqualTo(new Color(darkFogRed, darkFogGreen, darkFogBlue)));
            Assert.That(row.SunFogAmount, Is.EqualTo(lightFog));
            Assert.That(row.MoonFogAmount, Is.EqualTo(darkFog));
            Assert.That(row.Main1Color1, Is.EqualTo(main1Color1));
            Assert.That(row.Main1Color2, Is.EqualTo(main1Color2));
            Assert.That(row.Main1Color3, Is.EqualTo(main1Color3));
            Assert.That(row.Main1Color4, Is.EqualTo(main1Color4));
            Assert.That(row.Main2Color1, Is.EqualTo(main2Color1));
            Assert.That(row.Main2Color2, Is.EqualTo(main2Color2));
            Assert.That(row.Main2Color3, Is.EqualTo(main2Color3));
            Assert.That(row.Main2Color4, Is.EqualTo(main2Color4));
            Assert.That(row.SecondaryColor1, Is.EqualTo(secondaryColor1));
            Assert.That(row.SecondaryColor2, Is.EqualTo(secondaryColor2));
            Assert.That(row.SecondaryColor3, Is.EqualTo(secondaryColor3));
            Assert.That(row.SecondaryColor4, Is.EqualTo(secondaryColor4));
            Assert.That(row.WindPower, Is.EqualTo(wind));
            Assert.That(row.SnowChance, Is.EqualTo(snow));
            Assert.That(row.RainChance, Is.EqualTo(rain));
            Assert.That(row.LightningChance, Is.EqualTo(lightning));
            Assert.That(row.ShadowAlpha, Is.EqualTo(shadowAlpha));
        }
コード例 #18
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void PlaceableTableReturnsValidData(int rowIndex, string label, uint?strRef, string modelName, int?lightColor, float?lightOffsetX, float?lightOffsetY, float?lightOffsetZ, int?soundAppType, ShadowSize?shadowSize, bool?bodyBag, string lowGore, string reflection, bool?staticAllowed)
        {
            TwoDimArray <PlaceableTableEntry> table = NwGameTables.PlaceableTable;
            PlaceableTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.StrRef?.Id, Is.EqualTo(strRef));
            Assert.That(row.ModelName, Is.EqualTo(modelName));
            Assert.That(row.LightColor?.RowIndex, Is.EqualTo(lightColor));
            Assert.That(row.LightOffset?.X, Is.EqualTo(lightOffsetX));
            Assert.That(row.LightOffset?.Y, Is.EqualTo(lightOffsetY));
            Assert.That(row.LightOffset?.Z, Is.EqualTo(lightOffsetZ));
            Assert.That(row.SoundType?.RowIndex, Is.EqualTo(soundAppType));
            Assert.That(row.ShadowSize, Is.EqualTo(shadowSize));
            Assert.That(row.HasBodyBag, Is.EqualTo(bodyBag));
            Assert.That(row.LowGore, Is.EqualTo(lowGore));
            Assert.That(row.Reflection, Is.EqualTo(reflection));
            Assert.That(row.StaticAllowed, Is.EqualTo(staticAllowed));
        }
コード例 #19
0
ファイル: NwGameTableTests.cs プロジェクト: nwn-dotnet/Anvil
        public void VisualEffectTableReturnsValidData(int rowIndex, string label, string typeFd, bool orientWithGround, string impHeadConNode,
                                                      string impImpactNode, string impRootSNode, string impRootMNode, string impRootLNode, string impRootHNode, int?progFxImpact,
                                                      string soundImpact, int?progFxDuration, string soundDuration, int?progFxCessation, string soundCessation, string cesHeadConNode,
                                                      string cesImpactNode, string cesRootSNode, string cesRootMNode, string cesRootLNode, string cesRootHNode, int?shakeType,
                                                      float?shakeDelay, float?shakeDuration, string lowViolence, string lowQuality, bool?orientWithObject)
        {
            TwoDimArray <VisualEffectTableEntry> table = NwGameTables.VisualEffectTable;
            VisualEffectTableEntry row = table.GetRow(rowIndex);

            Assert.That(row.RowIndex, Is.EqualTo(rowIndex));
            Assert.That(row.Label, Is.EqualTo(label));
            Assert.That(row.TypeFd, Is.EqualTo(typeFd));
            Assert.That(row.OrientWithGround, Is.EqualTo(orientWithGround));
            Assert.That(row.ImpHeadConNode, Is.EqualTo(impHeadConNode));
            Assert.That(row.ImpImpactNode, Is.EqualTo(impImpactNode));
            Assert.That(row.ImpRootSmallNode, Is.EqualTo(impRootSNode));
            Assert.That(row.ImpRootMediumNode, Is.EqualTo(impRootMNode));
            Assert.That(row.ImpRootLargeNode, Is.EqualTo(impRootLNode));
            Assert.That(row.ImpRootHugeNode, Is.EqualTo(impRootHNode));
            Assert.That(row.ProgFxImpact?.RowIndex, Is.EqualTo(progFxImpact));
            Assert.That(row.SoundImpact, Is.EqualTo(soundImpact));
            Assert.That(row.ProgFxDuration?.RowIndex, Is.EqualTo(progFxDuration));
            Assert.That(row.SoundDuration, Is.EqualTo(soundDuration));
            Assert.That(row.ProgFxCessastion, Is.EqualTo(progFxCessation));
            Assert.That(row.SoundCessastion, Is.EqualTo(soundCessation));
            Assert.That(row.CesHeadConNode, Is.EqualTo(cesHeadConNode));
            Assert.That(row.CesImpactNode, Is.EqualTo(cesImpactNode));
            Assert.That(row.CesRootSmallNode, Is.EqualTo(cesRootSNode));
            Assert.That(row.CesRootMediumNode, Is.EqualTo(cesRootMNode));
            Assert.That(row.CesRootLargeNode, Is.EqualTo(cesRootLNode));
            Assert.That(row.CesRootHugeNode, Is.EqualTo(cesRootHNode));
            Assert.That((int?)row.ShakeType, Is.EqualTo(shakeType));
            Assert.That(row.ShakeDelay, Is.EqualTo(shakeDelay));
            Assert.That(row.ShakeDuration, Is.EqualTo(shakeDuration));
            Assert.That(row.LowViolenceVariant, Is.EqualTo(lowViolence));
            Assert.That(row.LowQualityVariant, Is.EqualTo(lowQuality));
            Assert.That(row.OrientWithObject, Is.EqualTo(orientWithObject));
        }
コード例 #20
0
        static void Main(string[] args)
        {
            #region TASK_2 , _1 TESTS
            int[] arr = new int[5] {
                6, 2, 9, -3, 6
            };
            int actualValue   = StaticClass.DividedByNumber(arr);
            int expectedValue = 2;

            AssertEquals(expectedValue, actualValue);

            int[] actual   = StaticClass.ArrayFromTextFile();
            int[] expected = new int[15] {
                16, 123, 23, 123, 12334, 34, 5634, 123, 0, 123, 0, 343, 0, 43, 42
            };

            AssertEquals(actual, expected);
            #endregion

            #region TASK_3 TESTS
            //Class constructor test
            int[] expectedArray = new int[5] {
                2, 5, 8, 11, 14
            };
            int[] actualArray = new OneDimArray(5, 2, 3).GetArr;

            AssertEquals(expectedArray, actualArray);

            expectedArray = new int[10] {
                8, 6, 4, 2, 0, -2, -4, -6, -8, -10
            };
            actualArray = new OneDimArray(10, 8, -2).GetArr;

            AssertEquals(expectedArray, actualArray);
            //
            //
            //
            //INVERSE METHOD TESTS
            expectedArray = new int[5] {
                -2, -5, -8, -11, -14
            };
            actualArray = new OneDimArray(5, 2, 3).Inverse();

            AssertEquals(expectedArray, actualArray);

            expectedArray = new int[10] {
                -8, -6, -4, -2, 0, 2, 4, 6, 8, 10
            };
            actualArray = new OneDimArray(10, 8, -2).Inverse();

            AssertEquals(expectedArray, actualArray);
            //
            //
            //
            //MULTI METHOD TESTS
            expectedArray = new int[10] {
                24, 18, 12, 6, 0, -6, -12, -18, -24, -30
            };
            actualArray = new OneDimArray(10, 8, -2).Multi(3);

            AssertEquals(expectedArray, actualArray);
            //
            //
            //
            //SUMMARY PROPERTY TESTS
            expectedValue = 40;
            actualValue   = new OneDimArray(5, 2, 3).Summary;

            AssertEquals(expectedValue, actualValue);

            expectedValue = -10;
            actualValue   = new OneDimArray(10, 8, -2).Summary;

            AssertEquals(expectedValue, actualValue);
            //
            //
            //CLASS DICTIONARY TEST
            //GET_ELEM_FREQ TEST
            Dictionary <int, int> testColl = new Dictionary <int, int>(4);
            testColl.Add(4, 1);
            testColl.Add(1, 1);
            testColl.Add(5, 1);
            testColl.Add(0, 1);
            Dictionary <int, double> expectedDict = new Dictionary <int, double>(4);
            expectedDict.Add(4, 0.25);
            expectedDict.Add(1, 0.25);
            expectedDict.Add(5, 0.25);
            expectedDict.Add(0, 0.25);

            Dictionary <int, double> actualDict = _Dictionary.GetElemFreq(testColl);

            AssertEquals(expectedDict, actualDict);
            #endregion

            #region TASK_4 Demonstration
            //Account.AccountCheck(Account.GetAccountDataBase());

            #endregion

            #region TASK_5_a demonstration
            TwoDimArray dimArray = new TwoDimArray(2, 2);
            int[,] testArr = dimArray.GetArr;
            for (int i = 0; i < dimArray.GetStringCount; i++)
            {
                for (int j = 0; j < dimArray.GetColCount; j++)
                {
                    Console.Write($"{testArr[i, j]} ");
                }
                Console.Write("\n");
            }

            //ALL_SUMM METHOD
            Console.WriteLine($"{dimArray.AllSumm()}");
            //MORE_THAN METHOD
            Console.WriteLine($"{dimArray.MoreThanSum(58000)}");
            //INDEX_OF METHOD
            foreach (int index in dimArray.IndexOf(dimArray.GetArrMax))
            {
                Console.Write($"[{index}], ");
            }
            #endregion
        }