Ejemplo n.º 1
0
        public void Test_LoadConfigurationForFile()
        {
            var filePath = CreateConfigFile("config.json",
              new JObject(
                  new JProperty("SomeKey", "SomeValue")));

            var directory = new Directory(null, "dir");

            var fileMock = MockFile("file.ext", "", directory);
            directory.AddFile(fileMock.Object);

            var configFileMock = MockFile("file.ext.MusicFileCop.json", filePath, directory);            
            directory.AddFile(configFileMock.Object);
                      
            var mapper = new ConfigurationMapper();

            var configurationLoader = new ConfigurationLoader(mapper, MockDefaultConfigurationNode().Object);
            configurationLoader.LoadConfiguration(MockConfigurationNode().Object, fileMock.Object);

            var config = mapper.GetConfiguration(fileMock.Object);
            Assert.NotNull(config);

            Assert.Equal("SomeValue", config.GetValue("SomeKey"));
            

        }
Ejemplo n.º 2
0
        public void Test_FileInheritsDirectoryConfiguration()
        {
            var directoryConfig = CreateConfigFile("config1.json",
             new JObject(
                 new JProperty("SomeKey", "SomeValue")));
            
            var directory = new Directory(null, "Irrelevant");

            var directoryConfigMock = MockFile("MusicFileCop.json", directoryConfig, directory);
            var fileMock = MockFile("file1.ext", "", directory);

            directory.AddFile(directoryConfigMock.Object);
            directory.AddFile(fileMock.Object);

            
            var mapper = new ConfigurationMapper();
                       
            var configurationLoader = new ConfigurationLoader(mapper, MockDefaultConfigurationNode().Object);
            configurationLoader.LoadConfiguration(MockConfigurationNode().Object, directory);

            var fileConfig = mapper.GetConfiguration(fileMock.Object);

            Assert.NotNull(fileConfig);
            Assert.Equal("SomeValue", fileConfig.GetValue("SomeKey"));            
        }