A class that provides a friendly interface for managing the settings of a T:Stumps.IStumpRule object.
コード例 #1
0
        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"));
 }
コード例 #3
0
        public void FindInteger_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = 15;

            Assert.AreEqual(expected, helper.FindInteger("good", expected));
        }
コード例 #4
0
        public void FindBooelan_WithInvalidSetting_ReturnsDefault()
        {
            var helper = new RuleSettingsHelper();

            Assert.IsFalse(helper.FindBoolean("good", false));
            Assert.IsTrue(helper.FindBoolean("good", true));
        }
コード例 #5
0
        public void FindString_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = "goodbye";

            Assert.AreEqual(expected, helper.FindString("good", expected));
        }
コード例 #6
0
        public void AddForByteArray_WithValidValue_UpdatesDictionary()
        {
            var helper = new RuleSettingsHelper();

            helper.Add("good", new byte[] { 1, 2, 3 });
            Assert.AreEqual(1, helper.Count);
        }
コード例 #7
0
        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"));
 }
コード例 #9
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"));
        }
コード例 #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));
 }