A class that provides a friendly interface for managing the settings of a T:Stumps.IStumpRule object.
        public void FindByteArray_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = new byte[] { 1, 2, 3 };

            CollectionAssert.AreEqual(expected, helper.FindByteArray("good", expected));
        }
예제 #2
0
 public void AddForInteger_WithNullSettingName_ThrowsException()
 {
     var helper = new RuleSettingsHelper();
     Assert.That(
         () => helper.Add(null, 15),
         Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("settingName"));
 }
        public void FindInteger_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = 15;

            Assert.AreEqual(expected, helper.FindInteger("good", expected));
        }
        public void FindBooelan_WithInvalidSetting_ReturnsDefault()
        {
            var helper = new RuleSettingsHelper();

            Assert.IsFalse(helper.FindBoolean("good", false));
            Assert.IsTrue(helper.FindBoolean("good", true));
        }
        public void FindString_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = "goodbye";

            Assert.AreEqual(expected, helper.FindString("good", expected));
        }
        public void AddForByteArray_WithValidValue_UpdatesDictionary()
        {
            var helper = new RuleSettingsHelper();

            helper.Add("good", new byte[] { 1, 2, 3 });
            Assert.AreEqual(1, helper.Count);
        }
        public void AddForBoolean_WithValidValue_UpdatesDictionary()
        {
            var helper = new RuleSettingsHelper();

            helper.Add("good", true);
            Assert.AreEqual(1, helper.Count);
        }
예제 #8
0
 public void AddForByteArray_WithNullValue_ThrowsException()
 {
     var helper = new RuleSettingsHelper();
     byte[] bytes = null;
     Assert.That(
         () => helper.Add("good", bytes),
         Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("value"));
 }
        public void AddForInteger_WithNullSettingName_ThrowsException()
        {
            var helper = new RuleSettingsHelper();

            Assert.That(
                () => helper.Add(null, 15),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settingName"));
        }
예제 #10
0
        public void AddForString_WithNullValue_ThrowsException()
        {
            var    helper = new RuleSettingsHelper();
            string s      = null;

            Assert.That(
                () => helper.Add("good", s),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("value"));
        }
예제 #11
0
        public void AddForByteArray_WithEmptyValue_ThrowsException()
        {
            var helper = new RuleSettingsHelper();

            byte[] bytes = new byte[0];
            Assert.That(
                () => helper.Add("good", bytes),
                Throws.Exception.TypeOf <ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("value"));
        }
예제 #12
0
        public void FindBooelan_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = true;
            var defaultValue = false;

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindBoolean("good", defaultValue));
        }
예제 #13
0
        public void FindInteger_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = 15;
            var defaultValue = 20;

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindInteger("good", defaultValue));
        }
예제 #14
0
        public void FindString_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = "hello";
            var defaultValue = "goodbye";

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindString("good", defaultValue));
        }
예제 #15
0
        public void FindByteArray_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = new byte[] { 1, 2, 3 };
            var defaultValue = new byte[] { 4, 5, 6 };

            helper.Add("good", expected);
            CollectionAssert.AreEqual(expected, helper.FindByteArray("good", defaultValue));
        }
예제 #16
0
        public void AddForExistingSetting_UpdatesSetting_UpdatesDictionary()
        {
            var expected = "override";
            var helper   = new RuleSettingsHelper();

            helper.Add("good", true);
            helper.Add("good", expected);
            Assert.AreEqual(1, helper.Count);
            Assert.AreEqual(expected, helper.FindString("good", "good"));
        }
예제 #17
0
        public void AddForExistingSetting_UpdatesSetting_UpdatesDictionary()
        {
            var expected = "override";
            var helper = new RuleSettingsHelper();

            helper.Add("good", true);
            helper.Add("good", expected);
            Assert.AreEqual(1, helper.Count);
            Assert.AreEqual(expected, helper.FindString("good", "good"));
        }
예제 #18
0
        public void Constructor_WithSetting_Initializes(string settingName, string settingValue, int expectedCount)
        {
            var setting = new RuleSetting
            {
                Name  = settingName,
                Value = settingValue
            };

            var helper = new RuleSettingsHelper(
                new RuleSetting[]
            {
                setting
            });

            Assert.AreEqual(expectedCount, helper.Count);
        }
예제 #19
0
 public void FindInteger_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = 15;
     var defaultValue = 20;
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindInteger("good", defaultValue));
 }
예제 #20
0
 public void FindByteArray_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = new byte[] { 1, 2, 3 };
     CollectionAssert.AreEqual(expected, helper.FindByteArray("good", expected));
 }
예제 #21
0
 public void FindByteArray_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = new byte[] { 1, 2, 3 };
     var defaultValue = new byte[] { 4, 5, 6 };
     helper.Add("good", expected);
     CollectionAssert.AreEqual(expected, helper.FindByteArray("good", defaultValue));
 }
예제 #22
0
 public void AddForByteArray_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", new byte[] { 1, 2, 3 });
     Assert.AreEqual(1, helper.Count);
 }
예제 #23
0
 public void FindBooelan_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     Assert.IsFalse(helper.FindBoolean("good", false));
     Assert.IsTrue(helper.FindBoolean("good", true));
 }
예제 #24
0
 public void FindBooelan_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = true;
     var defaultValue = false;
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindBoolean("good", defaultValue));
 }
예제 #25
0
        public void Constructor_WithSetting_Initializes(string settingName, string settingValue, int expectedCount)
        {
            var setting = new RuleSetting
            {
                Name = settingName,
                Value = settingValue
            };

            var helper = new RuleSettingsHelper(
                new RuleSetting[]
                {
                    setting
                });

            Assert.AreEqual(expectedCount, helper.Count);
        }
예제 #26
0
 public void AddForStringr_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", "good");
     Assert.AreEqual(1, helper.Count);
 }
예제 #27
0
 public void FindString_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = "goodbye";
     Assert.AreEqual(expected, helper.FindString("good", expected));
 }
예제 #28
0
        public void Constructor_Default_InitializesEmptyDictionary()
        {
            var helper = new RuleSettingsHelper();

            Assert.AreEqual(0, helper.Count);
        }
예제 #29
0
 public void FindInteger_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = 15;
     Assert.AreEqual(expected, helper.FindInteger("good", expected));
 }
예제 #30
0
 public void Constructor_Default_InitializesEmptyDictionary()
 {
     var helper = new RuleSettingsHelper();
     Assert.AreEqual(0, helper.Count);
 }
예제 #31
0
 public void FindString_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = "hello";
     var defaultValue = "goodbye";
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindString("good", defaultValue));
 }