public void SettingsFile_MergeSectionsInto_WithSectionsInCommon_ReturnsConfigWithAllSectionsMerged() { // Arrange var nugetConfigPath = "NuGet.Config"; var config = @" <configuration> <Section1> <add key='key1' value='value1' /> </Section1> <Section2> <add key='key2' value='value2' /> </Section2> <Section3> <add key='key3' value='value3' /> </Section3> </configuration>"; using (var mockBaseDirectory = TestDirectory.Create()) { SettingsTestUtils.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config); var settingsFile = new SettingsFile(mockBaseDirectory); // Act var settingsDict = new Dictionary <string, VirtualSettingSection>() { { "Section2", new VirtualSettingSection("Section2", new AddItem("keyX", "valueX")) }, { "Section3", new VirtualSettingSection("Section3", new AddItem("key3", "valueY")) }, { "Section4", new VirtualSettingSection("Section4", new AddItem("key4", "value4")) } }; settingsFile.MergeSectionsInto(settingsDict); var expectedSettingsDict = new Dictionary <string, VirtualSettingSection>() { { "Section2", new VirtualSettingSection("Section2", new AddItem("keyX", "valueX"), new AddItem("key2", "value2")) }, { "Section3", new VirtualSettingSection("Section3", new AddItem("key3", "value3")) }, { "Section4", new VirtualSettingSection("Section4", new AddItem("key4", "value4")) }, { "Section1", new VirtualSettingSection("Section1", new AddItem("key1", "value1")) }, }; foreach (var pair in settingsDict) { expectedSettingsDict.TryGetValue(pair.Key, out var expectedSection).Should().BeTrue(); SettingsTestUtils.DeepEquals(pair.Value, expectedSection).Should().BeTrue(); expectedSettingsDict.Remove(pair.Key); } expectedSettingsDict.Should().BeEmpty(); } }