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); }
public void TestInitialize() { TestsHelper.SetupLogger(); _configurationMockHelper = new ConfigurationMockHelper(new string[] { "DynamicallyLoadedDlls" }, new string[] { "Plugin1", "Plugin2" }, new ConfigurationMockHelper.AssemblyInfo[] { new ConfigurationMockHelper.AssemblyInfo(OroptimizerSharedAssemblyAlias, "OROptimizer.Shared", Helpers.TestsEntryAssemblyFolder), new ConfigurationMockHelper.AssemblyInfo(IoCConfigAssemblyAlias, "IoC.Configuration", Helpers.TestsEntryAssemblyFolder), new ConfigurationMockHelper.AssemblyInfo(IoCConfigurationTestsAssemblyAlias, "IoC.Configuration.Tests", Helpers.TestsEntryAssemblyFolder), new ConfigurationMockHelper.AssemblyInfo(SharedTestServicesAssemblyAlias, "TestProjects.SharedServices", Helpers.TestsEntryAssemblyFolder), new ConfigurationMockHelper.AssemblyInfo(MsCoreLibAssemblyAlias, typeof(int).Assembly.GetName().Name, Path.GetDirectoryName(typeof(int).Assembly.Location)), new ConfigurationMockHelper.AssemblyInfo(DynamicallyLoadedAssembly1Alias, "TestProjects.DynamicallyLoadedAssembly1", Path.Combine(TestFilesFolder, "DynamicallyLoadedDlls")), new ConfigurationMockHelper.AssemblyInfo(DynamicallyLoadedAssembly2Alias, "TestProjects.DynamicallyLoadedAssembly2", Path.Combine(TestFilesFolder, "DynamicallyLoadedDlls")), new ConfigurationMockHelper.AssemblyInfo(TestPluginAssembly1Alias, "TestProjects.TestPluginAssembly1", Path.Combine(TestFilesFolder, "PluginDlls", "Plugin1")), new ConfigurationMockHelper.AssemblyInfo(TestPluginAssembly2Alias, "TestProjects.TestPluginAssembly2", Path.Combine(TestFilesFolder, "PluginDlls", "Plugin2")) }); _configurationMockHelper.ConfigureTypeDefinitions(new ConfigurationMockHelper.TypeDefinitionInfo[] { new ConfigurationMockHelper.TypeDefinitionInfo(TypeDef1, typeof(IInterface1).FullName), new ConfigurationMockHelper.TypeDefinitionInfo(TypeDef2, "System.Collections.Generic.IEnumerable[SharedServices.Interfaces.IInterface1]"), }); var pluginAssemblyTypeUsageValidatorMock = new Mock <IPluginAssemblyTypeUsageValidator>(); pluginAssemblyTypeUsageValidatorMock.Setup(x => x.Validate(It.IsAny <IConfigurationFileElement>(), It.IsAny <ITypeInfo>())); _assemblyLocator = new AssemblyLocator(() => _configurationMockHelper.ConfigurationMock.Object, Helpers.TestsEntryAssemblyFolder); _typeHelper = new TypeHelper(_assemblyLocator, new TypeParser(), pluginAssemblyTypeUsageValidatorMock.Object); }