Example #1
0
        public void FahClientSettingsModel_Server_HasError()
        {
            var    model = new FahClientSettingsModel();
            string error = model[nameof(FahClientSettingsModel.Server)];

            Assert.IsNotNull(error);
        }
Example #2
0
        public void FahClientSettingsModel_ValidateAcceptance_ReturnsTrueWhenModelHasNoError()
        {
            var model = new FahClientSettingsModel();

            model.Name   = "foo";
            model.Server = "foo";
            Assert.IsTrue(model.ValidateAcceptance());
        }
Example #3
0
        public void FahClientSettingsModel_ConnectEnabled_ReturnsTrueWhenModelHasNoError()
        {
            var model = new FahClientSettingsModel();

            model.Name   = "foo";
            model.Server = "foo";
            Assert.IsTrue(model.ConnectEnabled);
        }
Example #4
0
        public void FahClientSettingsModel_Port_HasError()
        {
            var model = new FahClientSettingsModel();

            model.Port = 0;
            string error = model[nameof(FahClientSettingsModel.Port)];

            Assert.IsNotNull(error);
        }
Example #5
0
        public void FahClientSettingsModel_ConnectEnabled_SetFalseReturnsFalse()
        {
            var model = new FahClientSettingsModel();

            model.Name           = "foo";
            model.Server         = "foo";
            model.ConnectEnabled = false;
            Assert.IsFalse(model.ConnectEnabled);
        }
Example #6
0
        public void FahClientSettingsModel_StringPropertiesSetValuesAreTrimmed()
        {
            var model = new FahClientSettingsModel();

            model.Name = "  foo  ";
            Assert.AreEqual("foo", model.Name);
            model.Server = "bar   ";
            Assert.AreEqual("bar", model.Server);
            model.Password = "******";
            Assert.AreEqual("fizz", model.Password);
        }
Example #7
0
        public void FahClientSettingsModel_StringPropertiesSetNullAreSetEmptyString()
        {
            var model = new FahClientSettingsModel();

            model.Name = null;
            Assert.AreEqual(String.Empty, model.Name);
            model.Server = null;
            Assert.AreEqual(String.Empty, model.Server);
            model.Password = null;
            Assert.AreEqual(String.Empty, model.Password);
        }
Example #8
0
        public void FahClientSettingsModel_ValidateAcceptance_RaisesPropertyChanged()
        {
            // Arrange
            var    model        = new FahClientSettingsModel();
            string propertyName = null;

            model.PropertyChanged += (s, e) => propertyName = e.PropertyName;
            // Act
            model.ValidateAcceptance();
            // Assert
            Assert.AreEqual(String.Empty, propertyName);
        }
Example #9
0
        public void FahClientSettingsModel_DefaultPropertyValues()
        {
            var model = new FahClientSettingsModel();

            Assert.IsFalse(model.ConnectEnabled);
            Assert.AreEqual(String.Empty, model.Name);
            Assert.AreEqual(String.Empty, model.Server);
            Assert.AreEqual(ClientSettings.DefaultPort, model.Port);
            Assert.AreEqual(String.Empty, model.Password);
            Assert.AreEqual(default(Guid), model.Guid);
            Assert.IsNotNull(model.Slots);
        }
Example #10
0
        public void FahClientSettingsModel_Save_ToClientSettings()
        {
            // Arrange
            var guid  = Guid.NewGuid();
            var model = new FahClientSettingsModel
            {
                Name     = "Foo",
                Server   = "Bar",
                Port     = 12345,
                Password = "******",
                Guid     = guid
            };

            // Act
            model.Save();
            // Assert
            Assert.AreEqual(ClientType.FahClient, model.ClientSettings.ClientType);
            Assert.AreEqual("Foo", model.ClientSettings.Name);
            Assert.AreEqual("Bar", model.ClientSettings.Server);
            Assert.AreEqual(12345, model.ClientSettings.Port);
            Assert.AreEqual("fizzbizz", model.ClientSettings.Password);
            Assert.AreEqual(guid, model.ClientSettings.Guid);
        }
Example #11
0
        public void FahClientSettingsModel_Load_FromClientSettings()
        {
            // Arrange
            var guid     = Guid.NewGuid();
            var settings = new ClientSettings
            {
                Name     = "Foo",
                Server   = "Bar",
                Port     = 12345,
                Password = "******",
                Guid     = guid
            };
            var model = new FahClientSettingsModel(settings);

            // Act
            model.Load();
            // Assert
            Assert.AreEqual("Foo", model.Name);
            Assert.AreEqual("Bar", model.Server);
            Assert.AreEqual(12345, model.Port);
            Assert.AreEqual("fizzbizz", model.Password);
            Assert.AreEqual(guid, model.Guid);
        }
Example #12
0
        public void FahClientSettingsModel_RefreshSlots_FromClientObjectModel()
        {
            // Arrange
            var model          = new FahClientSettingsModel();
            var slotCollection = new SlotCollection();
            var slotOptions    = new SlotOptions {
                { Options.ClientType, "foo" }, { Options.MaxPacketSize, "bar" }
            };

            slotCollection.Add(new Slot {
                ID = 0, Description = "cpu:15", SlotOptions = slotOptions
            });
            // Act
            model.RefreshSlots(slotCollection);
            // Assert
            Assert.AreEqual(1, model.Slots.Count);
            var slotModel = model.Slots.First();

            Assert.AreEqual("00", slotModel.ID);
            Assert.AreEqual("CPU", slotModel.SlotType);
            Assert.AreEqual("foo", slotModel.ClientType);
            Assert.AreEqual("bar", slotModel.MaxPacketSize);
        }
Example #13
0
        public void FahClientSettingsModel_ValidateAcceptance_ReturnsTrueWhenModelHasError()
        {
            var model = new FahClientSettingsModel();

            Assert.IsFalse(model.ValidateAcceptance());
        }
Example #14
0
 public void DataBind(FahClientSettingsModel settings)
 {
    ClientNameTextBox.DataBindings.Add("Text", settings, "Name", false, DataSourceUpdateMode.OnValidation);
    AddressTextBox.DataBindings.Add("Text", settings, "Server", false, DataSourceUpdateMode.OnValidation);
    AddressPortTextBox.DataBindings.Add("Text", settings, "Port", false, DataSourceUpdateMode.OnValidation);
    PasswordTextBox.DataBindings.Add("Text", settings, "Password", false, DataSourceUpdateMode.OnValidation);
    _slotsGridBindingSource.DataSource = settings.Slots;
    SlotsDataGridView.DataSource = _slotsGridBindingSource;
 }