Beispiel #1
0
        private void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary <string, ToolStrip> itemLocationHash)
        {
            if (toolStrip != null)
            {
                toolStrip.Visible = settings.Visible;
                toolStrip.Size    = settings.Size;

                // Apply the item order changes.
                string itemNames = settings.ItemOrder;
                if (!string.IsNullOrEmpty(itemNames))
                {
                    string[] keys = itemNames.Split(',');
                    Regex    r    = new Regex("(\\S+)");

                    // Shuffle items according to string.
                    for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++)
                    {
                        Match match = r.Match(keys[i]);
                        if (match != null && match.Success)
                        {
                            string key = match.Value;
                            if (!string.IsNullOrEmpty(key) && itemLocationHash.ContainsKey(key))
                            {
                                toolStrip.Items.Insert(i, itemLocationHash[key].Items[key]);
                            }
                        }
                    }
                }
            }
        }
 private void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary<string, ToolStrip> itemLocationHash)
 {
     if (toolStrip != null)
     {
         toolStrip.Visible = settings.Visible;
         toolStrip.Size = settings.Size;
         string itemOrder = settings.ItemOrder;
         if (!string.IsNullOrEmpty(itemOrder))
         {
             string[] strArray = itemOrder.Split(new char[] { ',' });
             Regex regex = new Regex(@"(\S+)");
             for (int i = 0; (i < toolStrip.Items.Count) && (i < strArray.Length); i++)
             {
                 Match match = regex.Match(strArray[i]);
                 if ((match != null) && match.Success)
                 {
                     string str2 = match.Value;
                     if (!string.IsNullOrEmpty(str2) && itemLocationHash.ContainsKey(str2))
                     {
                         toolStrip.Items.Insert(i, itemLocationHash[str2].Items[str2]);
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 private void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary <string, ToolStrip> itemLocationHash)
 {
     if (toolStrip != null)
     {
         toolStrip.Visible = settings.Visible;
         toolStrip.Size    = settings.Size;
         string itemOrder = settings.ItemOrder;
         if (!string.IsNullOrEmpty(itemOrder))
         {
             string[] strArray = itemOrder.Split(new char[] { ',' });
             Regex    regex    = new Regex(@"(\S+)");
             for (int i = 0; (i < toolStrip.Items.Count) && (i < strArray.Length); i++)
             {
                 Match match = regex.Match(strArray[i]);
                 if ((match != null) && match.Success)
                 {
                     string str2 = match.Value;
                     if (!string.IsNullOrEmpty(str2) && itemLocationHash.ContainsKey(str2))
                     {
                         toolStrip.Items.Insert(i, itemLocationHash[str2].Items[str2]);
                     }
                 }
             }
         }
     }
 }
        private void GivenUnknownEvent()
        {
            var entry    = MockRepository.GenerateStub <EventLogEntry>();
            var settings = new SettingsStub();

            entry.Stub(x => x.InstanceId).Repeat.Any().Return(int.MaxValue);
            entry.Stub(x => x.Source).Repeat.Any().Return(settings.Source);
            entry.Stub(x => x.Message).Repeat.Any().Return(settings.Description);
            entry.Stub(x => x.EntryType).Repeat.Any().Return(EventLogEntryType.Error);

            this.entryWrittenEventArgs = new EntryWrittenEventArgs(entry);
        }
Beispiel #5
0
        private void LoadSettings_ValidatesIfIsExpectedValue <T>(string serializedSettingsValue, object expectedResult) where T : IStepSetting
        {
            SettingsStub settingsStub = new SettingsStub();

            settingsStub["Test"] = serializedSettingsValue;

            SettingsService service = new SettingsService(settingsStub);

            T actualResult = service.LoadSettings <T>("Test");

            Assert.AreEqual(expectedResult, actualResult);
        }
        private void GivenKnownEvent()
        {
            var entry = MockRepository.GenerateStub<EventLogEntry>();
            var settings = new SettingsStub();

            entry.Stub(x => x.InstanceId).Repeat.Any().Return(settings.EventId);
            entry.Stub(x => x.Source).Repeat.Any().Return(settings.Source);
            entry.Stub(x => x.Message).Repeat.Any().Return(settings.Description);
            entry.Stub(x => x.EntryType).Repeat.Any().Return(EventLogEntryType.Error);

            this.entryWrittenEventArgs = new EntryWrittenEventArgs(entry);
        }
Beispiel #7
0
        public void SaveSettings_SupplyValueForNonExistingParameter_SuccessfullyAddsValue()
        {
            // arrange
            TestSettings actualValue = new TestSettings {
                TestValue = 44
            };

            SettingsStub settingsStub = new SettingsStub();

            SettingsService service = new SettingsService(settingsStub);

            // act
            service.SaveSettings <TestSettings>("Test", actualValue);

            // assert
            Assert.AreEqual(JsonConvert.SerializeObject(actualValue), settingsStub["Test"]);
        }
Beispiel #8
0
 internal void Save()
 {
     foreach (ToolStrip strip in this.FindToolStrips(true, this.form.Controls))
     {
         if ((strip != null) && !string.IsNullOrEmpty(strip.Name))
         {
             ToolStripSettings settings = new ToolStripSettings(this.GetSettingsKey(strip));
             SettingsStub      stub     = new SettingsStub(strip);
             settings.ItemOrder          = stub.ItemOrder;
             settings.Name               = stub.Name;
             settings.Location           = stub.Location;
             settings.Size               = stub.Size;
             settings.ToolStripPanelName = stub.ToolStripPanelName;
             settings.Visible            = stub.Visible;
             settings.Save();
         }
     }
 }
Beispiel #9
0
        static Program()
        {
            #region SimpleInjector

            //_container = new Container();
            //_container.RegisterEventBusProducerDependencies(SettingsStub.GetSetting());
            //_container.Verify();

            #endregion

            #region Microsoft DependencyInjection

            _serviceProvider = new ServiceCollection()
                               .RegisterEventBusProducerDependencies(SettingsStub.GetSetting())
                               .BuildServiceProvider();

            #endregion
        }
Beispiel #10
0
        public void LoadSettings_SupplyValidSerializedSettingsString_ReturnsValidObject()
        {
            // arrange
            TestSettings expectedResult = new TestSettings {
                TestValue = 44
            };

            SettingsStub settingsStub = new SettingsStub();

            settingsStub["Test"] = JsonConvert.SerializeObject(expectedResult);

            SettingsService service = new SettingsService(settingsStub);

            // act
            TestSettings actualResult = service.LoadSettings <TestSettings>("Test");

            // assert
            AreEqualByJson(expectedResult, actualResult);
        }
Beispiel #11
0
        public void RemoveSettings_SupplyExistingParameterName_DeletesSettings()
        {
            // arrange
            TestSettings existingValue = new TestSettings {
                TestValue = 44
            };

            SettingsStub settingsStub = new SettingsStub();

            settingsStub["Test"] = JsonConvert.SerializeObject(existingValue);

            SettingsService service = new SettingsService(settingsStub);

            // act
            service.RemoveSettings("Test");

            // assert
            Assert.IsNull(settingsStub["Test"]);
        }
Beispiel #12
0
        internal void Save()
        {
            foreach (ToolStrip toolStrip in FindToolStrips(true, form.Controls))
            {
                if (toolStrip != null && !string.IsNullOrEmpty(toolStrip.Name))
                {
                    ToolStripSettings toolStripSettings = new ToolStripSettings(GetSettingsKey(toolStrip));
                    SettingsStub      stub = new SettingsStub(toolStrip);

                    toolStripSettings.ItemOrder          = stub.ItemOrder;
                    toolStripSettings.Name               = stub.Name;
                    toolStripSettings.Location           = stub.Location;
                    toolStripSettings.Size               = stub.Size;
                    toolStripSettings.ToolStripPanelName = stub.ToolStripPanelName;
                    toolStripSettings.Visible            = stub.Visible;

                    toolStripSettings.Save();
                }
            }
        }
Beispiel #13
0
        public void SaveSettings_SupplyValueForNonExistingParameter_SuccessfullyUpdatesValue()
        {
            // arrange
            TestSettings existingValue = new TestSettings {
                TestValue = 44
            };
            string existingJsonValue = JsonConvert.SerializeObject(existingValue);

            SettingsStub settingsStub = new SettingsStub();

            settingsStub["Test"] = existingJsonValue;

            SettingsService service = new SettingsService(settingsStub);

            existingValue.TestValue = 55;
            existingJsonValue       = JsonConvert.SerializeObject(existingValue);

            // act
            service.SaveSettings <TestSettings>("Test", existingValue);

            // assert
            Assert.AreEqual(existingJsonValue, settingsStub["Test"]);
        }
Beispiel #14
0
 static Program()
 {
     container = new Container();
     container.RegisterSendMailConsumerDependencies(SettingsStub.GetSetting());
     container.Verify();
 }
        internal void Save() {
            foreach (ToolStrip toolStrip in FindToolStrips(true, form.Controls)) {
                if (toolStrip != null && !string.IsNullOrEmpty(toolStrip.Name)) {
                    ToolStripSettings toolStripSettings = new ToolStripSettings(GetSettingsKey(toolStrip));
                    SettingsStub stub = new SettingsStub(toolStrip);

                    toolStripSettings.ItemOrder = stub.ItemOrder;
                    toolStripSettings.Name = stub.Name;
                    toolStripSettings.Location = stub.Location;
                    toolStripSettings.Size = stub.Size;
                    toolStripSettings.ToolStripPanelName = stub.ToolStripPanelName;
                    toolStripSettings.Visible = stub.Visible;
                    
                    toolStripSettings.Save();
                }
            }
        }
 private void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary<string, ToolStrip> itemLocationHash) {
     if (toolStrip != null) {
         toolStrip.Visible = settings.Visible;
         toolStrip.Size = settings.Size;
         
         // Apply the item order changes.
         string itemNames = settings.ItemOrder;
         if (!string.IsNullOrEmpty(itemNames)) {
             string[] keys = itemNames.Split(',');
             Regex r = new Regex("(\\S+)");
     
             // Shuffle items according to string.
             for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++) {
                 Match match = r.Match(keys[i]);
                 if (match != null && match.Success) {
                     string key = match.Value;
                     if (!string.IsNullOrEmpty(key) && itemLocationHash.ContainsKey(key)) {
                         toolStrip.Items.Insert(i, itemLocationHash[key].Items[key]);
                     }
                 }
             }
         }
     }
 }
 internal void Save()
 {
     foreach (ToolStrip strip in this.FindToolStrips(true, this.form.Controls))
     {
         if ((strip != null) && !string.IsNullOrEmpty(strip.Name))
         {
             ToolStripSettings settings = new ToolStripSettings(this.GetSettingsKey(strip));
             SettingsStub stub = new SettingsStub(strip);
             settings.ItemOrder = stub.ItemOrder;
             settings.Name = stub.Name;
             settings.Location = stub.Location;
             settings.Size = stub.Size;
             settings.ToolStripPanelName = stub.ToolStripPanelName;
             settings.Visible = stub.Visible;
             settings.Save();
         }
     }
 }
 static Program()
 {
     container = new Container();
     container.RegisterTestSomeActionExecutedConsumerDependencies(SettingsStub.GetSetting());
     container.Verify();
 }
 public void Initialize()
 {
     stub = new SettingsStub();
     stub.Saved += delegate { Output.Write(Colors.Green, "!! Saved"); };
     Read_Properties();
 }