public void ClientSettingsHttpTest()
        {
            // Arrange
             var settings = new LegacyClientSettingsModel();
             settings.LegacyClientSubType = LegacyClientSubType.Http;

             _settingsView.Expect(x => x.DataBind(settings));
             _settingsView.Expect(x => x.PathGroupVisible = false);
             _settingsView.Expect(x => x.HttpGroupVisible = true);
             _settingsView.Expect(x => x.FtpGroupVisible = false);
             // Act
             _presenter = CreatePresenter();
             _presenter.SettingsModel = settings;
             // Assert
             _settingsView.VerifyAllExpectations();
        }
 public void DefaultValueTest()
 {
     var model = new LegacyClientSettingsModel();
      Assert.AreEqual(LegacyClientSubType.Path, model.LegacyClientSubType);
      Assert.AreEqual(Constants.FahLogFileName, model.FahLogFileName);
      Assert.AreEqual(Constants.UnitInfoFileName, model.UnitInfoFileName);
      Assert.AreEqual(Constants.QueueFileName, model.QueueFileName);
      Assert.AreEqual(String.Empty, model.Server);
      Assert.AreEqual(Constants.DefaultFtpPort, model.Port);
      Assert.AreEqual(String.Empty, model.Username);
      Assert.AreEqual(String.Empty, model.Password);
      Assert.AreEqual(FtpType.Passive, model.FtpMode);
      Assert.AreEqual(false, model.UtcOffsetIsZero);
      Assert.AreEqual(0, model.ClientTimeOffset);
      Assert.AreEqual(String.Empty, model.Dummy);
 }
      public void ClientSettingsPathTest()
      {
         // Arrange
         var settings = new LegacyClientSettingsModel();
         settings.LegacyClientSubType = LegacyClientSubType.Path;

         _settingsView.Expect(x => x.DataBind(settings));
         _settingsView.Expect(x => x.PathGroupVisible = true);
         _settingsView.Expect(x => x.HttpGroupVisible = false);
         _settingsView.Expect(x => x.FtpGroupVisible = false);
         // Act
         _presenter = CreatePresenter();
         _presenter.SettingsModel = settings;
         // Assert
         // check on default Path instance - no need to replicate this assertion
         Assert.AreSame(settings, _presenter.SettingsModel);

         _settingsView.VerifyAllExpectations();
      }
        private static LegacyClientSettingsModel CreateValidModel(LegacyClientSubType type)
        {
            var model = new LegacyClientSettingsModel();
             model.LegacyClientSubType = type;
             model.Name = "Test";

             switch (type)
             {
            case LegacyClientSubType.Path:
               model.Path = "C:\\Folding";
               break;
            case LegacyClientSubType.Http:
               model.Path = "http://www.folding.com/";
               model.Username = "******";
               model.Password = "******";
               break;
            case LegacyClientSubType.Ftp:
               model.Path = "/path";
               model.Server = "123.123.123.123";
               model.Port = 45000;
               model.Username = "******";
               model.Password = "******";
               model.FtpMode = FtpType.Active;
               break;
             }

             Assert.IsFalse(model.Error);

             return model;
        }
 public void DataBind(LegacyClientSettingsModel settings)
 {
    ClientNameTextBox.DataBindings.Add("Text", settings, "Name", false, DataSourceUpdateMode.OnValidation);
    LogFileNameTextBox.DataBindings.Add("Text", settings, "FahLogFileName", false, DataSourceUpdateMode.OnValidation);
    UnitInfoFileNameTextBox.DataBindings.Add("Text", settings, "UnitInfoFileName", false, DataSourceUpdateMode.OnValidation);
    QueueFileNameTextBox.DataBindings.Add("Text", settings, "QueueFileName", false, DataSourceUpdateMode.OnValidation);
    LegacyClientSubTypePanel.DataSource = settings;
    LegacyClientSubTypePanel.ValueMember = "LegacyClientSubType";
    LogFolderTextBox.DataBindings.Add("Text", settings, "Path", false, DataSourceUpdateMode.OnValidation);
    WebUrlTextBox.DataBindings.Add("Text", settings, "Path", false, DataSourceUpdateMode.OnValidation);
    WebUsernameTextBox.DataBindings.Add("Text", settings, "Username", false, DataSourceUpdateMode.OnValidation);
    WebUsernameTextBox.DataBindings.Add("ErrorToolTipText", settings, "CredentialsErrorMessage", false, DataSourceUpdateMode.OnPropertyChanged);
    WebPasswordTextBox.DataBindings.Add("Text", settings, "Password", false, DataSourceUpdateMode.OnValidation);
    WebPasswordTextBox.DataBindings.Add("ErrorToolTipText", settings, "CredentialsErrorMessage", false, DataSourceUpdateMode.OnPropertyChanged);
    FtpServerNameTextBox.DataBindings.Add("Text", settings, "Server", false, DataSourceUpdateMode.OnValidation);
    FtpServerPortTextBox.DataBindings.Add("Text", settings, "Port", false, DataSourceUpdateMode.OnValidation);
    FtpServerPathTextBox.DataBindings.Add("Text", settings, "Path", false, DataSourceUpdateMode.OnValidation);
    FtpUsernameTextBox.DataBindings.Add("Text", settings, "Username", false, DataSourceUpdateMode.OnValidation);
    FtpUsernameTextBox.DataBindings.Add("ErrorToolTipText", settings, "CredentialsErrorMessage", false, DataSourceUpdateMode.OnPropertyChanged);
    FtpPasswordTextBox.DataBindings.Add("Text", settings, "Password", false, DataSourceUpdateMode.OnValidation);
    FtpPasswordTextBox.DataBindings.Add("ErrorToolTipText", settings, "CredentialsErrorMessage", false, DataSourceUpdateMode.OnPropertyChanged);
    FtpModePanel.DataSource = settings;
    FtpModePanel.ValueMember = "FtpMode";
    ClientNoUtcOffsetCheckBox.DataBindings.Add("Checked", settings, "UtcOffsetIsZero", false, DataSourceUpdateMode.OnPropertyChanged);
    ClientTimeOffsetUpDown.DataBindings.Add("Value", settings, "ClientTimeOffset", false, DataSourceUpdateMode.OnPropertyChanged);
    DummyTextBox.DataBindings.Add("Text", settings, "Dummy", false, DataSourceUpdateMode.Never);
 }
 private static LegacyClientSettingsModel CreateValidModel()
 {
     var model = new LegacyClientSettingsModel();
      model.LegacyClientSubType = LegacyClientSubType.Path;
      model.Name = "Test";
      model.FahLogFileName = "FAHlog.txt";
      model.UnitInfoFileName = "unitinfo.txt";
      model.QueueFileName = "queue.dat";
      model.Path = "C:\\";
      return model;
 }
 public void TestConnectionClickedHttpTest()
 {
     // Arrange
      var settings = new LegacyClientSettingsModel();
      settings.LegacyClientSubType = LegacyClientSubType.Http;
      _networkOps.Expect(x => x.BeginHttpCheckConnection(null, null, null, null)).IgnoreArguments().Return(null);
      // Act
      _presenter = CreatePresenter();
      _presenter.SettingsModel = settings;
      _presenter.TestConnectionClicked();
      // Assert
      _networkOps.VerifyAllExpectations();
 }
        public void LocalBrowseClickedTest()
        {
            // Arrange
             var settings = new LegacyClientSettingsModel();
             settings.Path = "C:\\";
             // Act
             _folderBrowserView.Expect(x => x.SelectedPath = settings.Path);
             _folderBrowserView.Expect(x => x.ShowDialog(_settingsView)).Return(DialogResult.OK);
             _folderBrowserView.Expect(x => x.SelectedPath).Return("D:\\").Repeat.Twice();
             // Assert
             _presenter = CreatePresenter();
             _presenter.SettingsModel = settings;
             _presenter.LocalBrowseClicked();

             Assert.AreEqual("D:\\", settings.Path);

             _folderBrowserView.VerifyAllExpectations();
        }