Beispiel #1
0
        public void TestSaveAndLoadConfiguration()
        {
            {
                // when
                Configuration configuration = WorkspaceFolder.LoadConfiguration();

                // then
                Assert.AreEqual(ButlerFactory.EmotionalJenkins, configuration.Butler);
                Assert.AreEqual(BusinessesFolder.CheckJobStatus, configuration.Business);
                Assert.AreEqual(50, configuration.DesktopMargin);
                Assert.IsFalse(WorkspaceFolder.HasConfigurationFile);
            }

            {
                // when
                WorkspaceFolder.Save(new Configuration()
                {
                    DesktopMargin = 40
                });

                // then
                Assert.IsTrue(WorkspaceFolder.HasConfigurationFile);
                Configuration configuration = WorkspaceFolder.LoadConfiguration();
                Assert.AreEqual(ButlerFactory.EmotionalJenkins, configuration.Butler);
                Assert.AreEqual(BusinessesFolder.CheckJobStatus, configuration.Business);
                Assert.AreEqual(40, configuration.DesktopMargin);
            }
        }
        private static void SetupFolder(string name, byte[] ps, byte[] psd)
        {
            WorkspaceFolder.ValidateAsFileName(name);
            string folder = GetFolder(name);

            WorkspaceFolder.SaveScriptIfNotExists(ps, folder, "main.ps1");
            WorkspaceFolder.SaveScriptIfNotExists(psd, Path.Combine(folder, "ja-JP"), "main.psd1");
        }
Beispiel #3
0
 private static void SaveResources(string butlerFolder, Butler butler, byte[] feelScript)
 {
     foreach (Appearance appearance in butler.Appearances.Values)
     {
         SaveIcon(appearance, butlerFolder);
         SaveImage(appearance, butlerFolder);
     }
     WorkspaceFolder.SaveScriptIfNotExists(feelScript, butlerFolder, "feel.ps1");
 }
Beispiel #4
0
        private static void SetupFolder(Butler butler, byte[] feelScript)
        {
            string name = butler.Name;

            WorkspaceFolder.ValidateAsFileName(name);
            string butlerFolder = GetFolder(name);

            CreateFolder(butlerFolder);
            SaveResources(butlerFolder, butler, feelScript);
            WorkspaceFolder.SaveObject(butler, GetSettingFile(name), false);
        }
        internal static Business Load(string name)
        {
            string file = GetSettingFile(name);

            if (File.Exists(file))
            {
                return((Business)WorkspaceFolder.LoadObject(file));
            }
            else
            {
                return(new Business());
            }
        }
Beispiel #6
0
        public void TestHasConfigurationFile()
        {
            {
                // expect
                Assert.IsFalse(WorkspaceFolder.HasConfigurationFile);
            }
            {
                // setup
                WorkspaceFolder.Save(new Configuration());

                // expect
                Assert.IsTrue(WorkspaceFolder.HasConfigurationFile);
            }
        }
Beispiel #7
0
        public void TestInitialize()
        {
            // when
            WorkspaceFolder.Initialize(new Configuration()
            {
                Butler = "abc", Business = "def"
            });

            // then
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Butlers", "abc")));
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Butlers", "Calm-Jenkins")));
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Butlers", "Emotional-Jenkins")));
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Businesses", "def")));
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Businesses", "Time-keeping")));
            Assert.IsTrue(Directory.Exists(Path.Combine(WorkspaceFolder.FullName, "Businesses", "Check-job-status")));
        }
Beispiel #8
0
 public void TestValidateAsFileName()
 {
     try
     {
         // when
         WorkspaceFolder.ValidateAsFileName("a:b");
         Assert.Fail("ここにはこない");
     }
     catch (ApplicationException e)
     {
         // then
         Console.WriteLine(e.Message);
     }
     {
         // expect
         WorkspaceFolder.ValidateAsFileName("abc.txt");
     }
 }
Beispiel #9
0
 internal static void Open(string name)
 {
     SetupFolderIfNotExists(name);
     WorkspaceFolder.Open(GetFolder(name));
 }
Beispiel #10
0
 internal static IEnumerable <string> GetFolderNames()
 {
     return(WorkspaceFolder.GetSubFolder(FullName));
 }
Beispiel #11
0
 private static Butler LoadButler(string name, string butlerSettingFile)
 {
     return((Butler)WorkspaceFolder.LoadObject(butlerSettingFile));
 }
 internal static void Save(string name, Business business)
 {
     SetupFolderIfNotExists(name);
     WorkspaceFolder.SaveObject(business, GetSettingFile(name), true);
 }