Esempio n. 1
0
        public void TestNameValidation()
        {
            Assert.IsTrue(BaseDatapack.ValidateName("anAme"), "name with only letters should be valid");
            Assert.IsTrue(BaseDatapack.ValidateName("an4m3"), "name with numbers should be valid");
            Assert.IsTrue(BaseDatapack.ValidateName("an_4m_3"), "name with _ should be valid");

            Assert.IsFalse(BaseDatapack.ValidateName("a name"), "name with space should not be valid");
            Assert.IsFalse(BaseDatapack.ValidateName("a!name"), "name with symbol should not be valid");
            Assert.IsFalse(BaseDatapack.ValidateName("    "), "empty name should not be valid");
        }
Esempio n. 2
0
 /// <summary>
 /// Enables the specified <see cref="SharpCraft.Datapack"/>
 /// </summary>
 /// <param name="datapack">the <see cref="SharpCraft.Datapack"/> to enable</param>
 /// <param name="placeAt">choses where the <see cref="SharpCraft.Datapack"/> should be placed relative to other enabled <see cref="SharpCraft.Datapack"/>s</param>
 /// <param name="otherPack">the <see cref="SharpCraft.Datapack"/> the <paramref name="datapack"/> is placed relative to</param>
 public void Enable(BaseDatapack datapack, ID.DatapackPlace placeAt, Datapack?otherPack = null)
 {
     if (otherPack is null)
     {
         ForFunction.AddCommand(new DatapackEnableCommand(datapack, placeAt == ID.DatapackPlace.first));
     }
     else
     {
         ForFunction.AddCommand(new DatapackEnableAtCommand(datapack, placeAt == ID.DatapackPlace.after, otherPack));
     }
 }
            public NamespaceTestClass(BaseDatapack datapack, string name) : base(datapack, name)
            {
                settings.Add(NamespaceSettings.GetSettings().FunctionGroupedCommands());

                #pragma warning disable IDE0067
                new BaseFileTestClass1(this, "file1", BaseFile.WriteSetting.OnDispose);
                new BaseFileTestClass1(this, "file2", BaseFile.WriteSetting.Auto);
                new BaseFileTestClass2(this, "file1", BaseFile.WriteSetting.Auto);
                new BaseFileTestClass2(this, "file2", BaseFile.WriteSetting.Auto);
                new BaseFileTestClass2(this, "file3", BaseFile.WriteSetting.LockedAuto);
                #pragma warning restore IDE0067
            }
Esempio n. 4
0
        public void TestDatapackListener()
        {
            BaseDatapack disposedpack = new DatapackTestClass("path", "disposedpack");

            disposedpack.Dispose();

            bool packCalled      = false;
            bool otherPackCalled = false;
            bool running         = true;

            using (BaseDatapack pack = new DatapackTestClass("path", "pack"))
            {
                BaseDatapack.AddDatapackListener((p) =>
                {
                    if (running)
                    {
                        if (p.Name == "pack")
                        {
                            packCalled = true;
                        }
                        else if (p.Name == "otherpack")
                        {
                            otherPackCalled = true;
                        }
                        else if (p.Name == "disposedpack")
                        {
                            Assert.Fail("disposed pack called datapack listeners (From " + nameof(TestDatapackListener) + ")");
                        }
                    }
                });
                Assert.IsTrue(packCalled, "pack didn't call datapack listener");
            }

            using (BaseDatapack pack = new DatapackTestClass("path", "otherpack"))
            {
                Assert.IsTrue(otherPackCalled, "new pack didn't call datapack listener");
            }
            running = false;
        }
Esempio n. 5
0
 /// <summary>
 /// Intializes a new <see cref="DatapackEnableCommand"/>
 /// </summary>
 /// <param name="datapack">The datapack to disable</param>
 /// <param name="loadFirst">True if the datapack should be loaded before others. False if it should be loaded last</param>
 public DatapackEnableCommand(BaseDatapack datapack, bool loadFirst)
 {
     Datapack  = datapack;
     LoadFirst = loadFirst;
 }
Esempio n. 6
0
 /// <summary>
 /// Intializes a new <see cref="DatapackDisableCommand"/>
 /// </summary>
 /// <param name="datapack">The datapack to disable</param>
 public DatapackDisableCommand(BaseDatapack datapack)
 {
     Datapack = datapack;
 }
Esempio n. 7
0
 /// <summary>
 /// Disables the specified <see cref="SharpCraft.Datapack"/>
 /// </summary>
 /// <param name="datapack">the <see cref="SharpCraft.Datapack"/> to disable</param>
 public void Disable(BaseDatapack datapack)
 {
     ForFunction.AddCommand(new DatapackDisableCommand(datapack));
 }
Esempio n. 8
0
 public NamespaceTestClass(BaseDatapack datapack, string name) : base(datapack, name)
 {
 }
Esempio n. 9
0
 public void TestPathValidation()
 {
     Assert.IsTrue(BaseDatapack.ValidatePath("anAhjfdkyg784 9y3uifdsme"), "path should be valid");
     Assert.IsFalse(BaseDatapack.ValidatePath("anAhjfdkyg784 9y3uifdsme/"), "path ends with / and should not be valid");
 }