Example #1
0
        public void TrySetValue3()
        {
            var settings = Create();

            foreach (var cur in settings.AllSettings)
            {
                SettingValue value = null;
                if (cur.Kind.IsToggleKind)
                {
                    value = SettingValue.NewToggleValue(true);
                }
                else if (cur.Kind.IsStringKind)
                {
                    value = SettingValue.NewStringValue("foo");
                }
                else if (cur.Kind.IsNumberKind)
                {
                    value = SettingValue.NewNumberValue(42);
                }
                else
                {
                    Assert.Fail();
                }

                Assert.IsTrue(settings.TrySetValue(cur.Abbreviation, value));
            }
        }
Example #2
0
        public void TrySetValue3()
        {
            foreach (var cur in _settings.AllSettings)
            {
                SettingValue value = null;
                if (cur.Kind.IsToggleKind)
                {
                    value = SettingValue.NewToggleValue(true);
                }
                else if (cur.Kind.IsStringKind)
                {
                    value = SettingValue.NewStringValue("foo");
                }
                else if (cur.Kind.IsNumberKind)
                {
                    value = SettingValue.NewNumberValue(42);
                }
                else
                {
                    throw new Exception("failed");
                }

                Assert.True(_settings.TrySetValue(cur.Abbreviation, value));
            }
        }
Example #3
0
        public void TrySetValue1()
        {
            Assert.True(_settings.TrySetValue(GlobalSettingNames.IgnoreCaseName, SettingValue.NewToggleValue(true)));
            var value = _settings.GetSetting(GlobalSettingNames.IgnoreCaseName);

            Assert.True(value.IsSome());
            Assert.Equal(true, value.Value.Value.AsToggleValue().Item);
        }
        public void PrintSetting3()
        {
            Create("foobar");
            var setting = new Setting("foobar", "fb", SettingKind.ToggleKind, SettingValue.NewToggleValue(true), SettingValue.NewToggleValue(true), false);

            _localSettings.Setup(x => x.GetSetting("foobar")).Returns(FSharpOption.Create(setting));
            _statusUtil.Setup(x => x.OnStatus("foobar")).Verifiable();
            _operations.PrintSetting("foobar");
            _statusUtil.Verify();
        }
        public void PrintAllSettings1()
        {
            Create("foobar");
            var setting = new Setting("foobar", "fb", SettingKind.NumberKind, SettingValue.NewToggleValue(false), SettingValue.NewToggleValue(false), false);

            _localSettings.Setup(x => x.AllSettings).Returns(Enumerable.Repeat(setting, 1));
            _statusUtil.Setup(x => x.OnStatusLong(It.IsAny <IEnumerable <string> >())).Verifiable();
            _operations.PrintAllSettings();
            _statusUtil.Verify();
        }
        public void InvertSettings1()
        {
            Create("foo");
            var setting = new Setting("foobar", "fb", SettingKind.ToggleKind, SettingValue.NewToggleValue(false), SettingValue.NewToggleValue(false), false);

            _localSettings.Setup(x => x.GetSetting("foobar")).Returns(FSharpOption.Create(setting)).Verifiable();
            _localSettings.Setup(x => x.TrySetValue("foobar", It.IsAny <SettingValue>())).Returns(true).Verifiable();
            _operations.InvertSetting("foobar");
            _localSettings.Verify();
        }
        public void InvertSettings2()
        {
            Create("foo");
            var setting = new Setting("foobar", "fb", SettingKind.NumberKind, SettingValue.NewToggleValue(false), SettingValue.NewToggleValue(false), false);

            _localSettings.Setup(x => x.GetSetting("foobar")).Returns(FSharpOption.Create(setting)).Verifiable();
            _statusUtil.Setup(x => x.OnError(Resources.CommandMode_InvalidArgument("foobar"))).Verifiable();
            _operations.InvertSetting("foobar");
            _localSettings.Verify();
            _statusUtil.Verify();
        }
Example #8
0
        public void SettingChanged1()
        {
            var settings = Create();
            var didRun   = false;

            settings.SettingChanged += (unused, setting) =>
            {
                Assert.AreEqual(ToggleSettingName, setting.Name);
                Assert.IsTrue(setting.AggregateValue.AsToggleValue().Item);
                didRun = true;
            };
            settings.TrySetValue(ToggleSettingName, SettingValue.NewToggleValue(true));
            Assert.IsTrue(didRun);
        }
Example #9
0
        public void SettingChanged1()
        {
            var didRun = false;

            _settings.SettingChanged += (unused, args) =>
            {
                var setting = args.Setting;
                Assert.Equal(ToggleSettingName, setting.Name);
                Assert.True(setting.AggregateValue.AsToggleValue().Item);
                didRun = true;
            };
            _settings.TrySetValue(ToggleSettingName, SettingValue.NewToggleValue(true));
            Assert.True(didRun);
        }
Example #10
0
 public void TrySetValueUp1()
 {
     _global.Setup(x => x.TrySetValue("notasetting", It.IsAny <SettingValue>())).Returns(false).Verifiable();
     Assert.IsFalse(_local.TrySetValue("notasetting", SettingValue.NewToggleValue(true)));
     _global.Verify();
 }