public void SaveTest()
        {
            GPlusImageDownloader.Properties.Settings.Default.Reset();

            SettingManager target = new SettingManager();
            var savingFlg = false;
            target.SavingSetting += (sender, e) => { savingFlg = true; };
            var savedFlg = false;
            target.SavedSetting += (sender, e) => { savedFlg = true; };
            var actualA = target.Save("hoge", "pwd", new DirectoryInfo("dir")).Result;

            Assert.IsTrue(actualA);
            Assert.IsTrue(savedFlg);
            Assert.IsTrue(savingFlg);
            Assert.AreEqual(target.EmailAddress, "hoge");
            Assert.AreEqual(target.Password, "pwd");
            Assert.AreEqual(target.ImageSaveDirectory.Name, "dir");

            savedFlg = false;
            target = new SettingManager();
            target.SavingSetting += (sender, e) => { e.Cancel = true; };
            target.SavedSetting += (sender, e) => { savedFlg = true; };
            Assert.AreEqual(target.EmailAddress, "hoge");
            Assert.AreEqual(target.Password, "pwd");
            Assert.AreEqual(target.ImageSaveDirectory.Name, "dir");
            var actualB = target.Save("hoge", "pwd", new DirectoryInfo("dir"));
            Assert.IsFalse(savedFlg);
        }
 public MainWindowModel()
 {
     Setting = new SettingManager();
     Setting.SavingSetting += Setting_SavingSetting;
     Setting.SavedSetting += Setting_SavedSetting;
     Downloader = new ImageDownloaderContainer(Setting);
     Downloader.RaiseError += Downloader_RaiseError;
 }
        public SettingViewModel(ImageDownloaderContainer jobContainer, SettingManager setting)
        {
            EmailAddress = setting.EmailAddress;
            Password = setting.Password;
            ImageSaveDirectory = setting.ImageSaveDirectory.FullName;
            NotificationText = string.Empty;

            PropertyChanged += SettingViewModel_PropertyChanged;
            SaveConfigCommand = new RelayCommand(
                async obj =>
                    {
                        NotificationText = string.Empty;
                        Status = SettingStatusType.Checking;
                        Status = (await setting.Save(
                            EmailAddress, Password, new System.IO.DirectoryInfo(ImageSaveDirectory)))
                            ? SettingStatusType.Normal : SettingStatusType.Error;

                        if (Status == SettingStatusType.Error)
                        {
                            NotificationText = "エラーが発生しました。メールアドレスやパスワード、画像保存先に異常がある事が考えられます。";
                            return;
                        }
                        IsModified = false;
                        IsExpanded = false;
                    });
            CancelConfigCommand = new RelayCommand(
                obj =>
                    {
                        EmailAddress = setting.EmailAddress;
                        Password = setting.Password;
                        ImageSaveDirectory = setting.ImageSaveDirectory.FullName;
                        NotificationText = string.Empty;
                        IsModified = false;
                        IsExpanded = false;
                    });
        }
 public ImageDownloaderContainer(SettingManager setting)
 {
     DownloadJobs = new List<ImageDownloader>();
     Setting = setting;
 }