public void Test_GetValue_Bool()
        {
            var node = new HierarchicalConfigurationNode(null,
                new ConfigurationMockHelper()
                .AddValue("SomeKey", "true")
                .AddValue("SomeKey2", "trUE")
                .AddValue("SomeKey3", "FALse")
                .Object);

            Assert.Equal(true, node.GetValue<bool>("SomeKey"));
            Assert.Equal(true, node.GetValue<bool>("SomeKey2"));
            Assert.Equal(false, node.GetValue<bool>("SomeKey3"));
        }
Ejemplo n.º 2
0
        public void Test_GetValue_Bool()
        {
            var node = new HierarchicalConfigurationNode(null,
                                                         new ConfigurationMockHelper()
                                                         .AddValue("SomeKey", "true")
                                                         .AddValue("SomeKey2", "trUE")
                                                         .AddValue("SomeKey3", "FALse")
                                                         .Object);

            Assert.Equal(true, node.GetValue <bool>("SomeKey"));
            Assert.Equal(true, node.GetValue <bool>("SomeKey2"));
            Assert.Equal(false, node.GetValue <bool>("SomeKey3"));
        }
        public void Test_GetValue_Int_Invalid()
        {
            var configuration = new ConfigurationMockHelper().AddValue("SomeKey", "sdafdv").Object;
            var node = new HierarchicalConfigurationNode(null, configuration);

            Assert.Throws<ArgumentException>(() => node.GetValue<int>("SomeKey"));
        }
        public void Test_GetValue_Int()
        {
            var configuration = new ConfigurationMockHelper().AddValue("SomeKey", "1234").Object;
            var node = new HierarchicalConfigurationNode(null, configuration);

            Assert.Equal(1234, node.GetValue<int>("SomeKey"));
        }
Ejemplo n.º 5
0
        public void Test_GetValue_Int_Invalid()
        {
            var configuration = new ConfigurationMockHelper().AddValue("SomeKey", "sdafdv").Object;
            var node          = new HierarchicalConfigurationNode(null, configuration);

            Assert.Throws <ArgumentException>(() => node.GetValue <int>("SomeKey"));
        }
Ejemplo n.º 6
0
        public void Test_GetValue_Int()
        {
            var configuration = new ConfigurationMockHelper().AddValue("SomeKey", "1234").Object;
            var node          = new HierarchicalConfigurationNode(null, configuration);

            Assert.Equal(1234, node.GetValue <int>("SomeKey"));
        }
        public void Test_GetValue_String()
        {
            var configurationMock = new ConfigurationMockHelper()
                .AddValue("SomeKey", "SomeValue")
                .Mock;

            var node = new HierarchicalConfigurationNode(null, configurationMock.Object);

            Assert.Equal("SomeValue", node.GetValue<string>("SomeKey"));
        }
Ejemplo n.º 8
0
        public void Test_GetValue_String()
        {
            var configurationMock = new ConfigurationMockHelper()
                                    .AddValue("SomeKey", "SomeValue")
                                    .Mock;

            var node = new HierarchicalConfigurationNode(null, configurationMock.Object);

            Assert.Equal("SomeValue", node.GetValue <string>("SomeKey"));
        }
Ejemplo n.º 9
0
        public void Test_GetValue_FromParentNode()
        {
            var expectedValue = Guid.NewGuid().ToString();

            var parentNodeMock = new Mock <IConfigurationNode>(MockBehavior.Strict);

            parentNodeMock.Setup(x => x.GetValue <string>("SomeKey")).Returns(expectedValue);

            var node = new HierarchicalConfigurationNode(parentNodeMock.Object, new ConfigurationMockHelper().Object);

            Assert.Equal(expectedValue, node.GetValue <string>("SomeKey"));
            parentNodeMock.Verify(x => x.GetValue <string>("SomeKey"), Times.Once);
        }
Ejemplo n.º 10
0
        public void Test_GetValue_NodeValueOverridesParentNodeValue()
        {
            var expectedValue = Guid.NewGuid().ToString();

            var parentNodeMock = new Mock <IConfigurationNode>(MockBehavior.Strict);

            parentNodeMock.Setup(x => x.GetValue <string>("SomeKey")).Returns("");

            var configuraiton = new ConfigurationMockHelper().AddValue("SomeKey", expectedValue).Object;
            var node          = new HierarchicalConfigurationNode(parentNodeMock.Object, configuraiton);

            Assert.Equal(expectedValue, node.GetValue <string>("SomeKey"));
            parentNodeMock.Verify(x => x.GetValue <string>("SomeKey"), Times.Never);
        }
        public void Test_GetValue_FromParentNode()
        {
            var expectedValue = Guid.NewGuid().ToString();

            var parentNodeMock = new Mock<IConfigurationNode>(MockBehavior.Strict);
            parentNodeMock.Setup(x => x.GetValue<string>("SomeKey")).Returns(expectedValue);

            var node = new HierarchicalConfigurationNode(parentNodeMock.Object, new ConfigurationMockHelper().Object);

            Assert.Equal(expectedValue, node.GetValue<string>("SomeKey"));
            parentNodeMock.Verify(x => x.GetValue<string>("SomeKey"), Times.Once);
        }
        public void Test_GetValue_NotFound()
        {
            var node = new HierarchicalConfigurationNode(null, new ConfigurationMockHelper().Object);

            Assert.Throws<KeyNotFoundException>(() => node.GetValue<string>("SomeKey"));
        }
        public void Test_GetValue_NodeValueOverridesParentNodeValue()
        {
            var expectedValue = Guid.NewGuid().ToString();

            var parentNodeMock = new Mock<IConfigurationNode>(MockBehavior.Strict);
            parentNodeMock.Setup(x => x.GetValue<string>("SomeKey")).Returns("");

            var configuraiton = new ConfigurationMockHelper().AddValue("SomeKey", expectedValue).Object;
            var node = new HierarchicalConfigurationNode(parentNodeMock.Object, configuraiton);
            
            Assert.Equal(expectedValue, node.GetValue<string>("SomeKey"));
            parentNodeMock.Verify(x => x.GetValue<string>("SomeKey"), Times.Never);
        }
Ejemplo n.º 14
0
        public void Test_GetValue_NotFound()
        {
            var node = new HierarchicalConfigurationNode(null, new ConfigurationMockHelper().Object);

            Assert.Throws <KeyNotFoundException>(() => node.GetValue <string>("SomeKey"));
        }