public void TestSetupFolderIfNotExists()
        {
            {
                // setup
                ButlersFolder.Initialize("abc");
                string folder = ButlersFolder.GetFolder("def");
                Assert.IsFalse(Directory.Exists(folder));

                // when
                ButlersFolder.SetupFolderIfNotExists("def");

                // then
                Assert.IsTrue(Directory.Exists(folder));
            }
            {
                // setup
                ButlersFolder.Initialize("abc");
                string butlerXml = Path.Combine(ButlersFolder.GetFolder("abc"), "Butler.xml");
                Assert.IsTrue(File.Exists(butlerXml));
                File.Delete(butlerXml);
                Assert.IsFalse(File.Exists(butlerXml));

                // when
                ButlersFolder.SetupFolderIfNotExists("abc");

                // then
                Assert.IsFalse(File.Exists(butlerXml));
            }
        }
        public void TestGetFolder()
        {
            // when
            string path = ButlersFolder.GetFolder("aaa");

            // then
            Console.WriteLine(path);
            Assert.IsTrue(path.EndsWith("\\Butlers\\aaa"));
        }
        public void TestLoad()
        {
            {
                // when
                Butler butler = ButlersFolder.Load("xxx");

                // then
                Assert.AreEqual("xxx", butler.Name);
                Assert.AreEqual("xxx", butler.DisplayName);
                Assert.AreEqual("xxx", butler.Nickname);
                Assert.AreSame(butler.Appearances[ButlerFactory.Normal].Image, butler.Image);
                Assert.AreEqual(Resources.jenkins.Width, butler.Image.PixelWidth);
                Assert.AreEqual(Resources.jenkins.Height, butler.Image.PixelHeight);
                Assert.AreEqual(Resources.jenkins_icon.Width, butler.Icon.Width);
                Assert.AreEqual(Resources.jenkins_icon.Height, butler.Icon.Height);
                Assert.IsFalse(Directory.Exists(ButlersFolder.GetFolder("xxx")));
            }
            {
                // setup
                ButlersFolder.Initialize("zzz");
                Assert.IsTrue(Directory.Exists(ButlersFolder.GetFolder("zzz")));

                // when
                string folder = ButlersFolder.GetFolder("zzz");
                TestUtil.Replace(Path.Combine(folder, "Butler.xml"),
                                 @"Nickname=""zzz""", @"Nickname=""yyy""");
                TestUtil.Replace(Path.Combine(folder, "Butler.xml"),
                                 @"MessageStyle Position=""Right"" Padding=""12,12,12,12"" FontSize=""14"" FontFamily=""Meiryo"" Width=""200"" Height=""200""",
                                 @"MessageStyle Position=""Right"" Padding=""12,12,12,12"" FontSize=""14"" FontFamily=""Meiryo"" BackgroundFile=""sad.png""");

                File.Copy(
                    Path.Combine(folder, "ninja.png"), Path.Combine(folder, "jenkins.png"), true);
                File.Copy(
                    TestUtil.GetTestResourcePath(@"Core\Folder\xpf.ico"),
                    Path.Combine(folder, "jenkins_icon.ico"), true);
                Butler butler = ButlersFolder.Load("zzz");

                // then
                Assert.AreEqual("zzz", butler.Name);
                Assert.AreEqual("zzz", butler.DisplayName);
                Assert.AreEqual("yyy", butler.Nickname);
                Assert.AreSame(butler.Appearances[ButlerFactory.Normal].Image, butler.Image);
                Assert.AreEqual(Resources.ninja.Width, butler.Image.PixelWidth);
                Assert.AreEqual(Resources.ninja.Height, butler.Image.PixelHeight);
                Assert.AreEqual(32, butler.Icon.Width);
                Assert.AreEqual(32, butler.Icon.Height);
                Assert.AreEqual("sad.png", butler.MessageStyle.BackgroundFile);
                Assert.AreEqual(Resources.sad.Width, butler.MessageStyle.Width);
                Assert.AreEqual(Resources.sad.Height, butler.MessageStyle.Height);
            }
        }
        public void TestOpen()
        {
            // setup
            WorkspaceFolder.processWrapper = new ProcessWrapperStub();
            ButlersFolder.Initialize("abc");
            string folder = ButlersFolder.GetFolder("def");

            Assert.IsFalse(Directory.Exists(folder));

            // when
            ButlersFolder.Open("def");

            // then
            Assert.IsTrue(Directory.Exists(folder));
            Assert.AreEqual(folder, ((ProcessWrapperStub)WorkspaceFolder.processWrapper).fileName);
        }
        public void TestInitialize()
        {
            {
                // when
                ButlersFolder.Initialize("xxx");

                // then
                string path = ButlersFolder.GetFolder("xxx");
                Console.WriteLine(path);
                Assert.IsTrue(path.EndsWith("\\Butlers\\xxx"));
                AssertEmotionalJenkins(path);

                string parent = Path.GetDirectoryName(path);
                AssertEmotionalJenkins(Path.Combine(parent, "Emotional-Jenkins"));
                AssertCalmJenkins(Path.Combine(parent, "Calm-Jenkins"));
            }

            {
                // when
                string path = ButlersFolder.GetFolder("xxx");
                TestUtil.ClearDirectory(path);
                ButlersFolder.Initialize("xxx");

                // then
                Assert.AreEqual(0, Directory.GetFiles(path).Length);
            }

            {
                // when
                string path = ButlersFolder.GetFolder("Emotional-Jenkins");
                CustomizeFolder(path);
                ButlersFolder.Initialize("xxx");

                // then
                AssertCustomizedFolder(path, 8);
            }

            {
                // when
                string path = ButlersFolder.GetFolder("Calm-Jenkins");
                CustomizeFolder(path);
                ButlersFolder.Initialize("xxx");

                // then
                AssertCustomizedFolder(path, 4);
            }
        }