public void GenerateXml_MoreAssemblies() { var typeStub1 = MockRepository.GenerateStub <Type> (); typeStub1.Stub(t => t.Assembly).Return(_assembly1); var typeStub2 = MockRepository.GenerateStub <Type> (); typeStub2.Stub(t => t.Assembly).Return(_assembly2); var assemblyIdentifierGeneratorStub = StubFactory.CreateIdentifierGeneratorStub(new[] { _assembly1, _assembly2 }); var typeIdentifierGeneratorStub = StubFactory.CreateIdentifierGeneratorStub(new[] { typeStub1, typeStub2 }); var involvedTypes = new[] { new InvolvedType(typeStub1), new InvolvedType(typeStub2) }; var reportGenerator = new AssemblyReportGenerator(involvedTypes, assemblyIdentifierGeneratorStub, typeIdentifierGeneratorStub); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Assemblies", new XElement( "Assembly", new XAttribute("id", "0"), new XAttribute("name", _assembly1.GetName().Name), new XAttribute("version", _assembly1.GetName().Version), new XAttribute("location", "./" + Path.GetFileName(_assembly1.Location)), new XAttribute("culture", _assembly1.GetName().CultureInfo), new XAttribute("publicKeyToken", Convert.ToBase64String(_assembly1.GetName().GetPublicKeyToken())), new XElement("InvolvedType-Reference", new XAttribute("ref", typeIdentifierGeneratorStub.GetIdentifier(typeStub1)))), new XElement( "Assembly", new XAttribute("id", "1"), new XAttribute("name", _assembly2.GetName().Name), new XAttribute("version", _assembly2.GetName().Version), // _assembly2 is of type object - which is a GAC (mscorlib.dll) new XAttribute("location", _assembly2.Location), new XAttribute("culture", _assembly2.GetName().CultureInfo), new XAttribute("publicKeyToken", Convert.ToBase64String(_assembly2.GetName().GetPublicKeyToken())), new XElement("InvolvedType-Reference", new XAttribute("ref", typeIdentifierGeneratorStub.GetIdentifier(typeStub2))))); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_AdditionalAssemblies() { var assemblyIdentifierGenerator = StubFactory.CreateIdentifierGeneratorStub(new[] { _assembly2 }); var reportGenerator = ReportBuilder.CreateAssemblyReportGenerator(assemblyIdentifierGenerator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Assemblies", new XElement( "Assembly", new XAttribute("id", "0"), new XAttribute("name", _assembly2.GetName().Name), new XAttribute("version", _assembly2.GetName().Version), new XAttribute("location", _assembly2.Location), new XAttribute("culture", _assembly2.GetName().CultureInfo), new XAttribute("publicKeyToken", Convert.ToBase64String(_assembly2.GetName().GetPublicKeyToken())) )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }