RemoveBindingRedirects() public method

public RemoveBindingRedirects ( IEnumerable bindingRedirects ) : void
bindingRedirects IEnumerable
return void
        public void RemoveBindingRedirectsDoesNotRemoveParentNodeIfNotLastElement()
        {
            // Arrange            
            var mockFileSystem = new MockFileSystem();
            mockFileSystem.AddFile("config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <runtime>
    <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
      <dependentAssembly>
        <assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" />
        <bindingRedirect oldVersion=""1.0.0.0"" newVersion=""2.0.0.0"" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name=""AssemblyName"" publicKeyToken=""token"" culture=""neutral"" />
        <bindingRedirect oldVersion=""0.0.0.0-3.0.0.0"" newVersion=""3.0.0.0"" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>");

            var bindingRedirectManager = new BindingRedirectManager(mockFileSystem, "config");
            AssemblyBinding assemblyBinding = GetAssemblyBinding("AssemblyName", "token", "3.0.0.0");

            // Act
            bindingRedirectManager.RemoveBindingRedirects(new[] { assemblyBinding });

            // Assert
            string outputContent = mockFileSystem.OpenFile("config").ReadToEnd();
            Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <runtime>
    <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
      <dependentAssembly>
        <assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" />
        <bindingRedirect oldVersion=""1.0.0.0"" newVersion=""2.0.0.0"" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>", outputContent);
        }
        public void RemoveBindingRedirectsRemovesParentNodeIfLastElement()
        {
            // Arrange
            var mockFileSystem = new Mock<IFileSystem>();
            mockFileSystem.Setup(m => m.FileExists("config")).Returns(true);
            mockFileSystem.Setup(m => m.OpenFile("config")).Returns(@"<?xml version=""1.0"" encoding=""utf-8""?>
            <configuration>
              <runtime>
            <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
            </assemblyBinding>
            <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
            <dependentAssembly>
            <assemblyIdentity name=""AssemblyName"" publicKeyToken=""token"" culture=""neutral"" />
            <bindingRedirect oldVersion=""0.0.0.0-3.0.0.0"" newVersion=""3.0.0.0"" />
              </dependentAssembly>
            </assemblyBinding>
              </runtime>
            </configuration>".AsStream());
            var ms = new MemoryStream();
            mockFileSystem.Setup(m => m.AddFile("config", It.IsAny<Stream>())).Callback<string, Stream>((path, stream) => {
                stream.CopyTo(ms);
                ms.Seek(0, SeekOrigin.Begin);
            });

            var bindingRedirectManager = new BindingRedirectManager(mockFileSystem.Object, "config");
            AssemblyBinding assemblyBinding = GetAssemblyBinding("A", "key", "3.0.0.0");

            // Act
            bindingRedirectManager.RemoveBindingRedirects(new[] { assemblyBinding });

            // Assert
            Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?>
            <configuration>
              <runtime>
            <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1""></assemblyBinding>
              </runtime>
            </configuration>", ms.ReadToEnd());
        }