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")); }
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")); }
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); }