示例#1
0
        public void should_correctly_convert_default_value()
        {
            var expectedValue = 100;
            var plugin = new IDSPlugin(null);

            var convertToDefaultValueMethod = plugin.GetType().GetMethod("ConvertToDefaultValue", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = convertToDefaultValueMethod.Invoke(plugin, new[] { " 100 ".AsBytes() });

            Assert.That(result, Is.TypeOf(typeof(int)));

            var castResult = (int)result;
            Assert.That(castResult, Is.EqualTo(expectedValue));
        }
示例#2
0
        public void should_correctly_convert_to_key_value_pair()
        {
            var expectedKey = 1;
            var expectedValue = "SomeValue";
            var plugin = new IDSPlugin(null);

            var convertToKeyValuePairMethod = plugin.GetType().GetMethod("ConvertToKeyValuePair", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = convertToKeyValuePairMethod.Invoke(plugin, new[] { "1 SomeValue ".AsBytes() });

            Assert.That(result, Is.TypeOf(typeof(KeyValuePair<int, string>)));

            var castResult = (KeyValuePair<int, string>)result;
            Assert.That(castResult.Key, Is.EqualTo(expectedKey));
            Assert.That(castResult.Value, Is.EqualTo(expectedValue));
        }
示例#3
0
        public void should_correctly_read_well_structured_encrypted_stream()
        {
            var dummyStream = CreateWellStructuredIDSStream(true);
            var plugin = new IDSPlugin(m_DummyEncryption);

            var expectedIDS = new IDSResource();
            expectedIDS.DefaultValue = 10;
            expectedIDS.Mappings.Add(1, "FirstValue");
            expectedIDS.Mappings.Add(2, "SecondValue");
            expectedIDS.Mappings.Add(3, "ThirdValue");

            var result = plugin.Import(dummyStream);

            Assert.That(result, Is.EqualTo(expectedIDS));
        }