public void GenerateXml_InterfaceDynamicallyImplemented() { var targetType = new InvolvedType (typeof (TargetClass3)); var mixinConfiguration = MixinConfiguration.BuildNew ().ForClass<TargetClass3> ().AddMixin<Mixin4> ().BuildConfiguration (); targetType.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First ()); targetType.TargetClassDefinition = new ReflectedObject (TargetClassDefinitionUtility.GetConfiguration (targetType.Type, mixinConfiguration)); var mixinContext = targetType.ClassContext.GetProperty ("Mixins").First (); var mixinDefinition = targetType.TargetClassDefinition.CallMethod ("GetMixinByConfiguredType", mixinContext.GetProperty ("MixinType").To<Type> ()); var assemblyIdentifierGenerator = new IdentifierGenerator<Assembly> (); var output = new TargetCallDependenciesReportGenerator (mixinDefinition, assemblyIdentifierGenerator, _remotionReflector, _outputFormatter).GenerateXml (); var expectedOutput = new XElement ("TargetCallDependencies", new XElement ("Dependency", new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "System"), new XAttribute ("name", "IDisposable"), new XAttribute ("is-interface", true), new XAttribute ("is-implemented-by-target", false), new XAttribute ("is-added-by-mixin", false), new XAttribute ("is-implemented-dynamically", true))); XElementComparisonHelper.Compare (output, expectedOutput); }
public void GenerateXml_WithIntroducedAttributes() { var attributeIdentifierGenerator = new IdentifierGenerator<Type>(); var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<UselessObject>().AddMixin<ObjectWithInheritableAttribute>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (UselessObject)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); var attributeIntroductions = GetAttributeIntroductions (type1, typeof (ObjectWithInheritableAttribute), mixinConfiguration); var reportGenerator = new AttributeIntroductionReportGenerator ( attributeIntroductions, attributeIdentifierGenerator, Helpers.RemotionReflectorFactory.GetRemotionReflection ()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "AttributeIntroductions", new XElement ( "IntroducedAttribute", new XAttribute ("ref", "0") )); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public MixinReferenceReportGenerator( InvolvedType involvedType, IIdentifierGenerator <Assembly> assemblyIdentifierGenerator, IIdentifierGenerator <Type> involvedTypeIdentifierGenerator, IIdentifierGenerator <Type> interfaceIdentifierGenerator, IIdentifierGenerator <Type> attributeIdentifierGenerator, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter ) { ArgumentUtility.CheckNotNull("involvedType", involvedType); ArgumentUtility.CheckNotNull("assemblyIdentifierGenerator", assemblyIdentifierGenerator); ArgumentUtility.CheckNotNull("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); ArgumentUtility.CheckNotNull("interfaceIdentifierGenerator", interfaceIdentifierGenerator); ArgumentUtility.CheckNotNull("attributeIdentifierGenerator", attributeIdentifierGenerator); ArgumentUtility.CheckNotNull("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull("outputFormatter", outputFormatter); _involvedType = involvedType; _assemblyIdentifierGenerator = assemblyIdentifierGenerator; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; _interfaceIdentifierGenerator = interfaceIdentifierGenerator; _attributeIdentifierGenerator = attributeIdentifierGenerator; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public void GenerateXml_OneAssembly() { var involvedType1 = new InvolvedType(typeof(TargetClass1)); var involvedType2 = new InvolvedType(typeof(TargetClass2)); var involvedType3 = new InvolvedType(typeof(Mixin1)); var involvedType4 = new InvolvedType(typeof(Mixin2)); var involvedTypes = new[] { involvedType1, involvedType2, involvedType3, involvedType4 }; var reportGenerator = ReportBuilder.CreateAssemblyReportGenerator(involvedTypes); 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", "0")), new XElement("InvolvedType-Reference", new XAttribute("ref", "1")), new XElement("InvolvedType-Reference", new XAttribute("ref", "2")), new XElement("InvolvedType-Reference", new XAttribute("ref", "3")) )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithNestedAttribute() { // ClassWithNestedAttribute has 'ClassWithNestedAttribute.NestedAttribute' applied var involvedType = new InvolvedType(typeof(ClassWithNestedAttribute)); var attributeIdentifier = new IdentifierGenerator <Type>(); attributeIdentifier.GetIdentifier(typeof(ClassWithNestedAttribute.NestedAttribute)); var reportGenerator = CreateReportGenerator(attributeIdentifier, involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Attributes", new XElement( "Attribute", new XAttribute("id", "0"), new XAttribute("assembly-ref", "0"), new XAttribute("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute("name", "ClassWithNestedAttribute+NestedAttribute"), new XElement( "AppliedTo", new XElement( "InvolvedType-Reference", new XAttribute("ref", "0") ) ) ) ); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public InvolvedTypeReportGenerator( InvolvedType[] involvedTypes, IIdentifierGenerator<Assembly> assemblyIdentifierGenerator, IIdentifierGenerator<Type> involvedTypeIdentifierGenerator, IIdentifierGenerator<MemberInfo> memberIdentifierGenerator, IIdentifierGenerator<Type> interfaceIdentifierGenerator, IIdentifierGenerator<Type> attributeIdentifierGenerator, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter) { ArgumentUtility.CheckNotNull ("involvedTypes", involvedTypes); ArgumentUtility.CheckNotNull ("assemblyIdentifierGenerator", assemblyIdentifierGenerator); ArgumentUtility.CheckNotNull ("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); ArgumentUtility.CheckNotNull ("memberIdentifierGenerator", memberIdentifierGenerator); ArgumentUtility.CheckNotNull ("interfaceIdentifierGenerator", interfaceIdentifierGenerator); ArgumentUtility.CheckNotNull ("attributeIdentifierGenerator", attributeIdentifierGenerator); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull ("outputFormatter", outputFormatter); _involvedTypes = involvedTypes; _assemblyIdentifierGenerator = assemblyIdentifierGenerator; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; _memberIdentifierGenerator = memberIdentifierGenerator; _interfaceIdentifierGenerator = interfaceIdentifierGenerator; _attributeIdentifierGenerator = attributeIdentifierGenerator; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public void GenerateXml_WithIntroducedInterfaces() { var interfaceIdentifierGenerator = new IdentifierGenerator<Type>(); var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<TargetClass2>().AddMixin<Mixin3>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (TargetClass2)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); // TargetClass2 does not implement any interface // Mixin3 introduces interface IDisposable var interfaceIntroductions = GetInterfaceIntroductions (type1, typeof (Mixin3), mixinConfiguration); var reportGenerator = new InterfaceIntroductionReportGenerator (interfaceIntroductions, interfaceIdentifierGenerator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "InterfaceIntroductions", new XElement ( "IntroducedInterface", new XAttribute ("ref", "0") )); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void GetOrCreateValue_EmptyStore() { var involvedType = _involvedTypeStore.GetOrCreateValue (typeof (object)); var expectedInvolvedType = new InvolvedType (typeof (object)); Assert.That (involvedType, Is.EqualTo (expectedInvolvedType)); }
public void GenerateXml_WithAttributes() { // Mixin2 has Serializable attribute var involvedType = new InvolvedType(typeof(Mixin2)); var attributeIdentifier = new IdentifierGenerator <Type>(); attributeIdentifier.GetIdentifier(typeof(SerializableAttribute)); var reportGenerator = CreateReportGenerator(attributeIdentifier, involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Attributes", new XElement( "Attribute", new XAttribute("id", "0"), new XAttribute("assembly-ref", "0"), new XAttribute("namespace", "System"), new XAttribute("name", "SerializableAttribute"), new XElement( "AppliedTo", new XElement( "InvolvedType-Reference", new XAttribute("ref", "0") ) ) ) ); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithIntroducedAttributes() { var attributeIdentifierGenerator = new IdentifierGenerator <Type>(); var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <UselessObject>().AddMixin <ObjectWithInheritableAttribute>() .BuildConfiguration(); var type1 = new InvolvedType(typeof(UselessObject)); type1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); var attributeIntroductions = GetAttributeIntroductions(type1, typeof(ObjectWithInheritableAttribute), mixinConfiguration); var reportGenerator = new AttributeIntroductionReportGenerator( attributeIntroductions, attributeIdentifierGenerator, Helpers.RemotionReflectorFactory.GetRemotionReflection()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "AttributeIntroductions", new XElement( "IntroducedAttribute", new XAttribute("ref", "0") )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithAttributes() { // Mixin2 has Serializable attribute var involvedType = new InvolvedType (typeof (Mixin2)); var attributeIdentifier = new IdentifierGenerator<Type>(); attributeIdentifier.GetIdentifier (typeof (SerializableAttribute)); var reportGenerator = CreateReportGenerator (attributeIdentifier, involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "Attributes", new XElement ( "Attribute", new XAttribute ("id", "0"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "System"), new XAttribute ("name", "SerializableAttribute"), new XElement ( "AppliedTo", new XElement ( "InvolvedType-Reference", new XAttribute ("ref", "0") ) ) ) ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public MixinReferenceReportGenerator( InvolvedType involvedType, IIdentifierGenerator<Assembly> assemblyIdentifierGenerator, IIdentifierGenerator<Type> involvedTypeIdentifierGenerator, IIdentifierGenerator<Type> interfaceIdentifierGenerator, IIdentifierGenerator<Type> attributeIdentifierGenerator, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter ) { ArgumentUtility.CheckNotNull ("involvedType", involvedType); ArgumentUtility.CheckNotNull ("assemblyIdentifierGenerator", assemblyIdentifierGenerator); ArgumentUtility.CheckNotNull ("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); ArgumentUtility.CheckNotNull ("interfaceIdentifierGenerator", interfaceIdentifierGenerator); ArgumentUtility.CheckNotNull ("attributeIdentifierGenerator", attributeIdentifierGenerator); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull ("outputFormatter", outputFormatter); _involvedType = involvedType; _assemblyIdentifierGenerator = assemblyIdentifierGenerator; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; _interfaceIdentifierGenerator = interfaceIdentifierGenerator; _attributeIdentifierGenerator = attributeIdentifierGenerator; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public void GenerateXml_WithOverriddenMembers() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <TargetDoSomething>().AddMixin <MixinDoSomething>() .BuildConfiguration(); var type1 = new InvolvedType(typeof(TargetDoSomething)); type1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); var memberOverrides = GetMemberOverrides(type1, typeof(MixinDoSomething), mixinConfiguration); var reportGenerator = new MemberOverrideReportGenerator(memberOverrides); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "MemberOverrides", new XElement( "OverriddenMember", new XAttribute("type", "Method"), new XAttribute("name", "DoSomething") )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GetHashCode_EqualObjects() { var type1 = new InvolvedType(typeof(TargetClass1)); var type2 = new InvolvedType(typeof(TargetClass1)); Assert.That(type1.GetHashCode(), Is.EqualTo(type2.GetHashCode())); }
public void GetOverrides_WithOverrides_ForMemberInBaseClass() { var targetType = typeof(BaseMemberOverrideTestClass.Target); var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <BaseMemberOverrideTestClass.Target> ().AddMixin <BaseMemberOverrideTestClass.Mixin1> () .BuildConfiguration(); var targetClassDefinition = new ReflectedObject(TargetClassDefinitionUtility.GetConfiguration(targetType, mixinConfiguration)); var involvedType = new InvolvedType(targetType) { TargetClassDefinition = targetClassDefinition, ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()) }; var reportGenerator = CreateMemberReportGenerator(targetType, involvedType); //var memberInfo = targetType.GetMember ("OverriddenMethod")[0]; var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Overrides", new XElement( "Mixin-Reference", new XAttribute("ref", 0), new XAttribute("instance-name", "BaseMemberOverrideTestClass+Mixin1") )); Assert.That(output.XPathSelectElement("Member[@name='OverriddenMethod']").Element("Overrides").ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithInterfaces() { // TargetClass1 implements IDisposable var involvedType = new InvolvedType(typeof(TargetClass1)); var reportGenerator = ReportBuilder.CreateInterfaceReportGenerator(_remotionReflector, _outputFormatter, involvedType); var output = reportGenerator.GenerateXml(); var memberReportGenerator = ReportBuilder.CreateMemberReportGenerator(typeof(IDisposable), _outputFormatter); var expectedOutput = new XElement( "Interfaces", new XElement( "Interface", new XAttribute("id", "0"), new XAttribute("assembly-ref", "0"), new XAttribute("namespace", "System"), new XAttribute("name", "IDisposable"), new XAttribute("is-composed-interface", false), memberReportGenerator.GenerateXml(), new XElement( "ImplementedBy", new XElement( "InvolvedType-Reference", new XAttribute("ref", "0")) ) )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void Equals_False_TypeDoesntMatch() { var type1 = new InvolvedType(typeof(TargetClass1)); var type2 = new InvolvedType(typeof(TargetClass2)); Assert.That(type1, Is.Not.EqualTo(type2)); }
public void MixinContextsProperty_ForNonMixin() { var type1 = new InvolvedType(typeof(object)); Assert.That(type1.IsMixin, Is.False); Assert.That(type1.TargetTypes.Count, Is.EqualTo(0)); }
public void GenerateXml_InterfaceDynamicallyImplemented() { var targetType = new InvolvedType(typeof(TargetClass3)); var mixinConfiguration = MixinConfiguration.BuildNew().ForClass <TargetClass3> ().AddMixin <Mixin4> ().BuildConfiguration(); targetType.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); targetType.TargetClassDefinition = new ReflectedObject(TargetClassDefinitionUtility.GetConfiguration(targetType.Type, mixinConfiguration)); var mixinContext = targetType.ClassContext.GetProperty("Mixins").First(); var mixinDefinition = targetType.TargetClassDefinition.CallMethod("GetMixinByConfiguredType", mixinContext.GetProperty("MixinType").To <Type> ()); var assemblyIdentifierGenerator = new IdentifierGenerator <Assembly> (); var output = new TargetCallDependenciesReportGenerator(mixinDefinition, assemblyIdentifierGenerator, _remotionReflector, _outputFormatter).GenerateXml(); var expectedOutput = new XElement("TargetCallDependencies", new XElement("Dependency", new XAttribute("assembly-ref", "0"), new XAttribute("namespace", "System"), new XAttribute("name", "IDisposable"), new XAttribute("is-interface", true), new XAttribute("is-implemented-by-target", false), new XAttribute("is-added-by-mixin", false), new XAttribute("is-implemented-dynamically", true))); XElementComparisonHelper.Compare(output, expectedOutput); }
public void GenerateXml_WithIntroducedInterfaces() { var interfaceIdentifierGenerator = new IdentifierGenerator <Type>(); var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <TargetClass2>().AddMixin <Mixin3>() .BuildConfiguration(); var type1 = new InvolvedType(typeof(TargetClass2)); type1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); // TargetClass2 does not implement any interface // Mixin3 introduces interface IDisposable var interfaceIntroductions = GetInterfaceIntroductions(type1, typeof(Mixin3), mixinConfiguration); var reportGenerator = new InterfaceIntroductionReportGenerator(interfaceIntroductions, interfaceIdentifierGenerator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "InterfaceIntroductions", new XElement( "IntroducedInterface", new XAttribute("ref", "0") )); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
private ReflectedObject GetAttributeIntroductions( InvolvedType targetType, Type mixinType, MixinConfiguration mixinConfiguration) { var targetClassDefinition = TargetClassDefinitionUtility.GetConfiguration(targetType.Type, mixinConfiguration); return(new ReflectedObject(targetClassDefinition.GetMixinByConfiguredType(mixinType).AttributeIntroductions)); }
public void FindInvolvedTypes_WithMoreTargets() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <TargetClass1>().AddMixin <Mixin1>() .ForClass <TargetClass2>().AddMixin <Mixin2>() .BuildConfiguration(); var involvedTypeFinder = CreateInvolvedTypeFinder(mixinConfiguration, new[] { typeof(Mixin1).Assembly }); var involvedTypes = involvedTypeFinder.FindInvolvedTypes(); var expectedType1 = new InvolvedType(typeof(TargetClass1)); expectedType1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); expectedType1.TargetClassDefinition = CreateTargetClassDefintion <TargetClass1> (mixinConfiguration); var expectedType2 = new InvolvedType(typeof(Mixin1)); expectedType2.TargetTypes.Add(expectedType1, expectedType1.TargetClassDefinition.CallMethod("GetMixinByConfiguredType", typeof(Mixin1))); var expectedType3 = new InvolvedType(typeof(TargetClass2)); expectedType3.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.Last()); expectedType3.TargetClassDefinition = CreateTargetClassDefintion <TargetClass2> (mixinConfiguration); var expectedType4 = new InvolvedType(typeof(Mixin2)); expectedType4.TargetTypes.Add(expectedType3, expectedType3.TargetClassDefinition.CallMethod("GetMixinByConfiguredType", typeof(Mixin2))); Assert.That(involvedTypes, Is.EquivalentTo(GetAdditonalAssemblyInvolvedTypes(expectedType1, expectedType2, expectedType3, expectedType4))); }
public void FindInvolvedTypes_WithTargetClassInheritance() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass <UselessObject>().AddMixin <Mixin1>() .BuildConfiguration(); var involvedTypeFinder = CreateInvolvedTypeFinder(mixinConfiguration, new[] { typeof(Mixin1).Assembly }); var involvedTypes = involvedTypeFinder.FindInvolvedTypes(); var expectedType1 = new InvolvedType(typeof(UselessObject)); expectedType1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); expectedType1.TargetClassDefinition = CreateTargetClassDefintion <UselessObject> (mixinConfiguration); var expectedType2 = new InvolvedType(typeof(ClassInheritsFromUselessObject)); expectedType2.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.GetWithInheritance(typeof(ClassInheritsFromUselessObject))); expectedType2.TargetClassDefinition = CreateTargetClassDefintion <ClassInheritsFromUselessObject> (mixinConfiguration); var expectedType3 = new InvolvedType(typeof(Mixin1)); expectedType3.TargetTypes.Add(expectedType1, expectedType1.TargetClassDefinition.CallMethod("GetMixinByConfiguredType", typeof(Mixin1))); expectedType3.TargetTypes.Add(expectedType2, expectedType2.TargetClassDefinition.CallMethod("GetMixinByConfiguredType", typeof(Mixin1))); Assert.That(involvedTypes, Is.EquivalentTo(GetAdditonalAssemblyInvolvedTypes(expectedType1, expectedType2, expectedType3))); }
public void GenerateXml_TargetClassWithOverriddenBaseClassMember() { var type = typeof(InheritatedTargetClass); var mixinConfiguration = MixinConfiguration.BuildNew().ForClass <InheritatedTargetClass> ().AddMixin <MixinOverridesTargetClassMember> ().BuildConfiguration(); var targetClassDefinition = new ReflectedObject(TargetClassDefinitionUtility.GetConfiguration(type, mixinConfiguration)); var involvedType = new InvolvedType(type) { TargetClassDefinition = targetClassDefinition }; var reportGenerator = CreateMemberReportGenerator(type, involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "Members", new XElement( "Member", new XAttribute("id", "0"), new XAttribute("type", MemberTypes.Constructor), new XAttribute("name", ".ctor"), new XAttribute("is-declared-by-this-class", true), _outputFormatter.CreateModifierMarkup("", "public"), _outputFormatter.CreateConstructorMarkup("InheritatedTargetClass", new ParameterInfo[0]) ), new XElement( "Member", new XAttribute("id", "1"), new XAttribute("type", MemberTypes.Method), new XAttribute("name", "MyBaseClassMethod"), new XAttribute("is-declared-by-this-class", false), _outputFormatter.CreateModifierMarkup("", "public virtual"), _outputFormatter.CreateMethodMarkup("MyBaseClassMethod", typeof(void), new ParameterInfo[0]), GenerateOverrides("Mixin-Reference", "0", "MixinOverridesTargetClassMember") ), new XElement( "Member", new XAttribute("id", "2"), new XAttribute("type", MemberTypes.Method), new XAttribute("name", "MyNewMethod"), new XAttribute("is-declared-by-this-class", true), _outputFormatter.CreateModifierMarkup("", "public virtual"), _outputFormatter.CreateMethodMarkup("MyNewMethod", typeof(void), new ParameterInfo[0]) ), new XElement( "Member", new XAttribute("id", "3"), new XAttribute("type", MemberTypes.Method), new XAttribute("name", "MyNonRelevantBaseClassMethod"), new XAttribute("is-declared-by-this-class", true), _outputFormatter.CreateModifierMarkup("", "public override"), _outputFormatter.CreateMethodMarkup("MyNonRelevantBaseClassMethod", typeof(void), new ParameterInfo[0]), GenerateOverrides("Mixin-Reference", "0", "MixinOverridesTargetClassMember") ) ); XElementComparisonHelper.Compare(output, expectedOutput); }
public void GetOrCreateValue_EmptyStore() { var involvedType = _involvedTypeStore.GetOrCreateValue(typeof(object)); var expectedInvolvedType = new InvolvedType(typeof(object)); Assert.That(involvedType, Is.EqualTo(expectedInvolvedType)); }
public TargetReferenceReportGenerator(InvolvedType mixinType, IIdentifierGenerator <Type> involvedTypeIdentifierGenerator) { ArgumentUtility.CheckNotNull("mixinType", mixinType); ArgumentUtility.CheckNotNull("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); _mixinType = mixinType; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; }
public void Equals_False_IsMixinDoesntMatch() { var type1 = new InvolvedType (typeof (TargetClass1)); var type2 = new InvolvedType (typeof (Mixin1)); type2.TargetTypes.Add (new InvolvedType(typeof (TargetClass1)), null); Assert.That (type1, Is.Not.EqualTo (type2)); }
public TargetReferenceReportGenerator(InvolvedType mixinType, IIdentifierGenerator<Type> involvedTypeIdentifierGenerator) { ArgumentUtility.CheckNotNull ("mixinType", mixinType); ArgumentUtility.CheckNotNull ("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); _mixinType = mixinType; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; }
public void Equals_False_IsTargetDoesntMatch() { var type1 = new InvolvedType(typeof(TargetClass1)); type1.ClassContext = new ReflectedObject(new ClassContext(typeof(TargetClass1))); var type2 = new InvolvedType(typeof(TargetClass1)); Assert.That(type1, Is.Not.EqualTo(type2)); }
public void MixinContextsProperty_ForMixin() { var type1 = new InvolvedType(typeof(object)); type1.TargetTypes.Add(new InvolvedType(typeof(TargetClass1)), null); Assert.That(type1.IsMixin, Is.True); Assert.That(type1.TargetTypes.Count, Is.GreaterThan(0)); }
public void Equals_False_IsMixinDoesntMatch() { var type1 = new InvolvedType(typeof(TargetClass1)); var type2 = new InvolvedType(typeof(Mixin1)); type2.TargetTypes.Add(new InvolvedType(typeof(TargetClass1)), null); Assert.That(type1, Is.Not.EqualTo(type2)); }
public void GenerateXml_NonMixin() { var type1 = new InvolvedType (typeof (object)); var reportGenerator = new TargetReferenceReportGenerator (type1, new IdentifierGenerator<Type>()); var output = reportGenerator.GenerateXml(); Assert.That (output, Is.Null); }
public void GenerateXml_NonMixin() { var type1 = new InvolvedType(typeof(object)); var reportGenerator = new TargetReferenceReportGenerator(type1, new IdentifierGenerator <Type>()); var output = reportGenerator.GenerateXml(); Assert.That(output, Is.Null); }
public void HasAlphabeticOrderingAttribute_False() { var involvedType = new InvolvedType(typeof(object)); var reportGenerator = ReportBuilder.CreateInvolvedTypeReportGenerator(_remotionReflector, _outputFormatter); var output = reportGenerator.GetAlphabeticOrderingAttribute(involvedType); Assert.That(output, Is.EqualTo("")); }
public InterfaceReferenceReportGenerator( InvolvedType involvedType, IIdentifierGenerator<Type> interfaceIdentifierGenerator, IRemotionReflector remotionReflector) { ArgumentUtility.CheckNotNull ("involvedType", involvedType); ArgumentUtility.CheckNotNull ("interfaceIdentifierGenerator", interfaceIdentifierGenerator); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); _involvedType = involvedType; _interfaceIdentifierGenerator = interfaceIdentifierGenerator; _remotionReflector = remotionReflector; }
public InterfaceReferenceReportGenerator( InvolvedType involvedType, IIdentifierGenerator <Type> interfaceIdentifierGenerator, IRemotionReflector remotionReflector) { ArgumentUtility.CheckNotNull("involvedType", involvedType); ArgumentUtility.CheckNotNull("interfaceIdentifierGenerator", interfaceIdentifierGenerator); ArgumentUtility.CheckNotNull("remotionReflector", remotionReflector); _involvedType = involvedType; _interfaceIdentifierGenerator = interfaceIdentifierGenerator; _remotionReflector = remotionReflector; }
public void GenerateXml_NoAttributes() { // UselessObject has no attributes var involvedType = new InvolvedType (typeof (UselessObject)); var reportGenerator = CreateReportGenerator (new IdentifierGenerator<Type>(), involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ("Attributes"); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void Equals_True() { var type1 = new InvolvedType(typeof(TargetClass1)); type1.ClassContext = new ReflectedObject(new ClassContext(typeof(TargetClass1))); var type2 = new InvolvedType(typeof(TargetClass1)); type2.ClassContext = new ReflectedObject(new ClassContext(typeof(TargetClass1))); Assert.That(type1, Is.EqualTo(type2)); }
public void GenerateXml_ZeroInterfaces() { var involvedType = new InvolvedType(typeof(object)); var reportGenerator = new InterfaceReferenceReportGenerator(involvedType, new IdentifierGenerator <Type>(), Helpers.RemotionReflectorFactory.GetRemotionReflection()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement("ImplementedInterfaces"); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void TargetClassDefinitionProperty_ForGenericTargetClass() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass(typeof(GenericTarget <,>)).AddMixin <Mixin1>() .BuildConfiguration(); var type1 = new InvolvedType(typeof(GenericTarget <,>)); type1.ClassContext = new ReflectedObject(mixinConfiguration.ClassContexts.First()); Assert.That(type1.IsTarget, Is.True); }
public void ClassContextProperty_ForTargetClass() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<TargetClass1>().AddMixin<Mixin1>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (TargetClass1)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); Assert.That (type1.IsTarget, Is.True); Assert.That (type1.ClassContext, Is.Not.Null); }
public void GenerateXml_NoAttributes() { // UselessObject has no attributes var involvedType = new InvolvedType(typeof(UselessObject)); var reportGenerator = CreateReportGenerator(new IdentifierGenerator <Type>(), involvedType); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement("Attributes"); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public AssemblyReportGenerator( InvolvedType[] involvedTypes, IIdentifierGenerator<Assembly> assemblyIdentifierGenerator, IIdentifierGenerator<Type> involvedTypeIdentifierGenerator) { ArgumentUtility.CheckNotNull ("involvedTypes", involvedTypes); ArgumentUtility.CheckNotNull ("assemblyIdentifierGenerator", assemblyIdentifierGenerator); ArgumentUtility.CheckNotNull ("involvedTypeIdentifierGenerator", involvedTypeIdentifierGenerator); _involvedTypes = involvedTypes; _assemblyIdentifierGenerator = assemblyIdentifierGenerator; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGenerator; }
public void GetMembers_ForClassWithNonPublicEvent() { var type = new InvolvedType(typeof(ClassWithNonPublicEvent)); var member = type.Members.FirstOrDefault(m => ((MemberInfo)m.MemberInfo).Name == "EventName"); Assert.That(member, Is.Not.Null); var subMemberInfos = member.SubMemberInfos.ToArray(); Assert.That(subMemberInfos.Length, Is.EqualTo(2)); Assert.That((MemberInfo)(subMemberInfos[0]), Is.Not.Null); Assert.That((MemberInfo)(subMemberInfos[1]), Is.Not.Null); }
public void GenerateXml_ForGenericTypeDefinition() { var targetType = new InvolvedType (typeof (GenericTarget<,>)); var mixinConfiguration = MixinConfiguration.BuildNew () .ForClass (typeof (GenericTarget<,>)).AddMixin<ClassWithBookAttribute> ().AddMixin<Mixin3> () .BuildConfiguration (); targetType.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First ()); var interfaceIdentifierGenerator = new IdentifierGenerator<Type> (); var attributeIdentifierGenerator = new IdentifierGenerator<Type> (); var assemblyIdentifierGenerator = new IdentifierGenerator<Assembly> (); var reportGenerator = new MixinReferenceReportGenerator ( targetType, assemblyIdentifierGenerator, // generic target class new IdentifierGenerator<Type> (), interfaceIdentifierGenerator, attributeIdentifierGenerator, _remotionReflector, _outputFormatter); var output = reportGenerator.GenerateXml (); var expectedOutput = new XElement ( "Mixins", new XElement ( "Mixin", new XAttribute ("ref", "0"), new XAttribute ("index", "n/a"), new XAttribute ("relation", "Extends"), new XAttribute ("instance-name", "ClassWithBookAttribute"), new XAttribute ("introduced-member-visibility", "private"), // has no dependencies new XElement ("AdditionalDependencies") ), new XElement ( "Mixin", new XAttribute ("ref", "1"), new XAttribute ("index", "n/a"), new XAttribute ("relation", "Extends"), new XAttribute ("instance-name", "Mixin3"), new XAttribute ("introduced-member-visibility", "private"), // has no dependencies new XElement ("AdditionalDependencies") ) ); Assert.That (output.ToString (), Is.EqualTo (expectedOutput.ToString ())); }
public void GenerateXml_WithInterfaces() { // TargetClass1 implements IDisposealbe var involvedType = new InvolvedType (typeof (TargetClass1)); var reportGenerator = new InterfaceReferenceReportGenerator (involvedType, new IdentifierGenerator<Type>(), Helpers.RemotionReflectorFactory.GetRemotionReflection ()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "ImplementedInterfaces", new XElement ("ImplementedInterface", new XAttribute ("ref", "0")) ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void Equals_False_ClassContextDoesntMatch() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<TargetClass1>().AddMixin<Mixin1>() .ForClass<TargetClass2>().AddMixin<Mixin2>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (TargetClass1)); var type2 = new InvolvedType (typeof (TargetClass1)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); type2.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.Last()); Assert.That (type1, Is.Not.EqualTo (type2)); }
public void GenerateXm_NoIntroducedInterfaces() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<TargetClass2>().AddMixin<Mixin2>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (TargetClass2)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); var interfaceIntroductions = GetInterfaceIntroductions (type1, typeof (Mixin2), mixinConfiguration); var reportGenerator = new InterfaceIntroductionReportGenerator (interfaceIntroductions, new IdentifierGenerator<Type>()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ("InterfaceIntroductions"); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void GenerateXml_NoIntroducedAttribute() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<TargetClass2>().AddMixin<Mixin1>() .BuildConfiguration(); var type1 = new InvolvedType (typeof (TargetClass2)); type1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First()); var attributeIntroductions = GetAttributeIntroductions (type1, typeof (Mixin1), mixinConfiguration); var reportGenerator = new AttributeIntroductionReportGenerator ( attributeIntroductions, new IdentifierGenerator<Type>(), Helpers.RemotionReflectorFactory.GetRemotionReflection ()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ("AttributeIntroductions"); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public FullReportGenerator( InvolvedType[] involvedTypes, ErrorAggregator<Exception> configurationErrors, ErrorAggregator<Exception> validationErrors, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter) { ArgumentUtility.CheckNotNull ("_involvedTypes", involvedTypes); ArgumentUtility.CheckNotNull ("configurationErrors", configurationErrors); ArgumentUtility.CheckNotNull ("validationErrors", validationErrors); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull ("outputFormatter", outputFormatter); _involvedTypes = involvedTypes; _configurationErrors = configurationErrors; _validationErrors = validationErrors; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public void GenerateXml_ForMixin() { var type1 = new InvolvedType (typeof (Mixin1)); type1.TargetTypes.Add (new InvolvedType(typeof (TargetClass1)), null); var reportGenerator = new TargetReferenceReportGenerator (type1, new IdentifierGenerator<Type>()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "Targets", new XElement ( "Target", new XAttribute ("ref", "0") ) ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public MemberReportGenerator( Type type, InvolvedType involvedTypeOrNull, IIdentifierGenerator<Type> involvedTypeIdentifierGeneratorOrNull, IIdentifierGenerator<MemberInfo> memberIdentifierGeneratorOrNull, IOutputFormatter outputFormatter) { ArgumentUtility.CheckNotNull ("type", type); // may be null // ArgumentUtility.CheckNotNull ("involvedTypeOrNull", involvedTypeOrNull); // ArgumentUtility.CheckNotNull ("involvedTypeIdentifierGeneratorOrNull", involvedTypeIdentifierGeneratorOrNull); // ArgumentUtility.CheckNotNull ("memberIdentifierGeneratorOrNull", memberIdentifierGeneratorOrNull); ArgumentUtility.CheckNotNull ("outputFormatter", outputFormatter); _type = type; _involvedType = involvedTypeOrNull; _involvedTypeIdentifierGenerator = involvedTypeIdentifierGeneratorOrNull; _memberIdentifierGenerator = memberIdentifierGeneratorOrNull; _outputFormatter = outputFormatter; _memberSignatureUtility = new MemberSignatureUtility (outputFormatter); }
public void MemberEquals_True() { var targetType = typeof (BaseMemberOverrideTestClass.Target); var mixinConfiguration = MixinConfiguration.BuildNew () .ForClass<BaseMemberOverrideTestClass.Target> ().AddMixin<BaseMemberOverrideTestClass.Mixin1> () .BuildConfiguration (); var targetClassDefinition = new ReflectedObject (TargetClassDefinitionUtility.GetConfiguration (targetType, mixinConfiguration)); var involvedType = new InvolvedType (targetType) { TargetClassDefinition = targetClassDefinition, ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First ()) }; var memberInfo1 = targetType.GetMember ("OverriddenMethod")[0]; var output = involvedType.TargetClassDefinition.CallMethod ("GetAllMembers").SingleOrDefault ( mdb => MemberInfoEqualityUtility.MemberEquals (mdb.GetProperty ("MemberInfo").To<MemberInfo> (), memberInfo1)); Assert.That (output.To<object> (), Is.Not.Null); }
public void GenerateXml_WithComposedInterface() { var mixinConfiguration = MixinConfiguration.BuildNew() .ForClass<ComposedInterfacesTestClass.MyMixinTarget>() .AddCompleteInterface<ComposedInterfacesTestClass.ICMyMixinTargetMyMixin>() .AddMixin<ComposedInterfacesTestClass.MyMixin>() .BuildConfiguration(); // MyMixinTarget does not implement any interfaces! (but ICMyMixinTargetMyMixin is added to class context as a composed interface) var involvedType = new InvolvedType (typeof (ComposedInterfacesTestClass.MyMixinTarget)); var classContext = mixinConfiguration.ClassContexts.GetWithInheritance (typeof (ComposedInterfacesTestClass.MyMixinTarget)); involvedType.ClassContext = new ReflectedObject (classContext); var reportGenerator = new InterfaceReferenceReportGenerator (involvedType, new IdentifierGenerator<Type>(), Helpers.RemotionReflectorFactory.GetRemotionReflection ()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "ImplementedInterfaces", new XElement ("ImplementedInterface", new XAttribute ("ref", "0")) ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void GenerateXml_WithComposedInterface() { var mixinConfiguration = MixinConfiguration.BuildNew () .ForClass<ComposedInterfacesTestClass.MyMixinTarget> () .AddCompleteInterface<ComposedInterfacesTestClass.ICMyMixinTargetMyMixin> () .AddMixin<ComposedInterfacesTestClass.MyMixin> () .BuildConfiguration (); var involvedType = new InvolvedType (typeof (ComposedInterfacesTestClass.MyMixinTarget)); var classContext = mixinConfiguration.ClassContexts.GetWithInheritance (typeof (ComposedInterfacesTestClass.MyMixinTarget)); involvedType.ClassContext = new ReflectedObject (classContext); var reportGenerator = ReportBuilder.CreateInterfaceReportGenerator (_remotionReflector, _outputFormatter, involvedType); var output = reportGenerator.GenerateXml (); var memberReportGenerator = ReportBuilder.CreateMemberReportGenerator (typeof (ComposedInterfacesTestClass.ICMyMixinTargetMyMixin), _outputFormatter); var expectedOutput = new XElement ( "Interfaces", new XElement ( "Interface", new XAttribute ("id", "0"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "ComposedInterfacesTestClass+ICMyMixinTargetMyMixin"), new XAttribute ("is-composed-interface", true), memberReportGenerator.GenerateXml (), new XElement ( "ImplementedBy", new XElement ( "InvolvedType-Reference", new XAttribute ("ref", "0")) ) )); Assert.That (output.ToString (), Is.EqualTo (expectedOutput.ToString ())); }
public void GenerateXml_DifferentAssemblies() { var involvedType1 = new InvolvedType (typeof (TargetClass1)) { ClassContext = new ReflectedObject (new ClassContext (typeof (TargetClass1))) }; var involvedType2 = new InvolvedType (typeof (object)); var reportGenerator = CreateInvolvedTypeReportGenerator (involvedType1, involvedType2); var output = reportGenerator.GenerateXml (); var expectedOutput = new XElement ( "InvolvedTypes", new XElement ( "InvolvedType", new XAttribute ("id", "0"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "TargetClass1"), new XAttribute ("base", "Object"), new XAttribute ("base-ref", "1"), new XAttribute ("is-target", true), new XAttribute ("is-mixin", false), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType1.Type)), _summaryPicker.GetSummary (involvedType1.Type), new MemberReportGenerator (involvedType1.Type, involvedType1, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType1, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType1.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType1, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType1, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () ), new XElement ( "InvolvedType", new XAttribute ("id", "1"), new XAttribute ("assembly-ref", "1"), new XAttribute ("namespace", "System"), new XAttribute ("name", "Object"), new XAttribute ("base", "none"), new XAttribute ("base-ref", "none"), new XAttribute ("is-target", false), new XAttribute ("is-mixin", false), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType2.Type)), _summaryPicker.GetSummary (involvedType2.Type), new MemberReportGenerator (involvedType2.Type, involvedType2, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType2, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType2.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType2, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType2, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () )); XElementComparisonHelper.Compare (output, expectedOutput); }
private void SetTargetClassDefinition(InvolvedType involvedType, MixinConfiguration mixinConfiguration) { involvedType.TargetClassDefinition = new ReflectedObject (TargetClassDefinitionUtility.GetConfiguration (involvedType.Type, mixinConfiguration)); }
public void HasAlphabeticOrderingAttribute_True() { var mixinConfiguration = MixinConfiguration.BuildNew ().ForClass<UselessObject> ().AddMixin<ClassWithAlphabeticOrderingAttribute> ().BuildConfiguration (); var involvedType = new InvolvedType (typeof (ClassWithAlphabeticOrderingAttribute)); involvedType.TargetTypes.Add ( new InvolvedType (typeof (UselessObject)), new ReflectedObject (TargetClassDefinitionUtility.GetConfiguration (typeof (UselessObject), mixinConfiguration).Mixins[0])); var reportGenerator = ReportBuilder.CreateInvolvedTypeReportGenerator (_remotionReflector, _outputFormatter); var output = reportGenerator.GetAlphabeticOrderingAttribute (involvedType); Assert.That (output, Is.EqualTo ("AcceptsAlphabeticOrdering ")); }
public void HasAlphabeticOrderingAttribute_False() { var involvedType = new InvolvedType (typeof (object)); var reportGenerator = ReportBuilder.CreateInvolvedTypeReportGenerator (_remotionReflector, _outputFormatter); var output = reportGenerator.GetAlphabeticOrderingAttribute (involvedType); Assert.That (output, Is.EqualTo ("")); }
public void GenerateXml_InvolvedTypes() { var mixinConfiguration = MixinConfiguration.BuildNew () .ForClass<TargetClass1> ().AddMixin<Mixin1> () .ForClass<TargetClass2> ().AddMixin<Mixin2> () .BuildConfiguration (); var involvedType1 = new InvolvedType (typeof (TargetClass1)); involvedType1.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.First ()); SetTargetClassDefinition (involvedType1, mixinConfiguration); var involvedType2 = new InvolvedType (typeof (TargetClass2)); involvedType2.ClassContext = new ReflectedObject (mixinConfiguration.ClassContexts.Last ()); SetTargetClassDefinition (involvedType2, mixinConfiguration); var involvedType3 = new InvolvedType (typeof (Mixin1)); involvedType3.TargetTypes.Add (new InvolvedType (typeof (TargetClass1)), null); var involvedType4 = new InvolvedType (typeof (Mixin2)); involvedType4.TargetTypes.Add (new InvolvedType (typeof (TargetClass2)), null); var reportGenerator = CreateInvolvedTypeReportGenerator (involvedType1, involvedType2, involvedType3, involvedType4); var output = reportGenerator.GenerateXml (); var expectedOutput = new XElement ( "InvolvedTypes", new XElement ( "InvolvedType", new XAttribute ("id", "0"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "TargetClass1"), new XAttribute ("base", "Object"), new XAttribute ("base-ref", "none"), new XAttribute ("is-target", true), new XAttribute ("is-mixin", false), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType1.Type)), _summaryPicker.GetSummary (involvedType1.Type), new MemberReportGenerator (involvedType1.Type, involvedType1, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType1, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType1.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType1, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType1, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () ), new XElement ( "InvolvedType", new XAttribute ("id", "1"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "TargetClass2"), new XAttribute ("base", "Object"), new XAttribute ("base-ref", "none"), new XAttribute ("is-target", true), new XAttribute ("is-mixin", false), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType2.Type)), _summaryPicker.GetSummary (involvedType2.Type), new MemberReportGenerator (involvedType2.Type, involvedType2, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType2, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType2.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType2, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType2, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () ), new XElement ( "InvolvedType", new XAttribute ("id", "2"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "Mixin1"), new XAttribute ("base", "Object"), new XAttribute ("base-ref", "none"), new XAttribute ("is-target", false), new XAttribute ("is-mixin", true), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType3.Type)), _summaryPicker.GetSummary (involvedType3.Type), new MemberReportGenerator (involvedType3.Type, involvedType3, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType3, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType3.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType3, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType3, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () ), new XElement ( "InvolvedType", new XAttribute ("id", "3"), new XAttribute ("assembly-ref", "0"), new XAttribute ("namespace", "MixinXRef.UnitTests.TestDomain"), new XAttribute ("name", "Mixin2"), new XAttribute ("base", "Object"), new XAttribute ("base-ref", "none"), new XAttribute ("is-target", false), new XAttribute ("is-mixin", true), new XAttribute ("is-unusedmixin", false), new XAttribute ("is-generic-definition", false), new XAttribute ("is-interface", false), _outputFormatter.CreateModifierMarkup ("", _typeModifierUtility.GetTypeModifiers (involvedType4.Type)), _summaryPicker.GetSummary (involvedType4.Type), new MemberReportGenerator (involvedType4.Type, involvedType4, _involvedTypeIdentifierGenerator, _memberIdentifierGenerator, _outputFormatter). GenerateXml (), new InterfaceReferenceReportGenerator (involvedType4, _interfaceIdentifierGenerator, _remotionReflector).GenerateXml (), new AttributeReferenceReportGenerator (involvedType4.Type, _attributeIdentifierGenerator, _remotionReflector).GenerateXml (), new MixinReferenceReportGenerator ( involvedType4, _assemblyIdentifierGenerator, _readOnlyInvolvedTypeIdentifierGenerator, _interfaceIdentifierGenerator, _attributeIdentifierGenerator, _remotionReflector, _outputFormatter). GenerateXml (), new TargetReferenceReportGenerator (involvedType4, _readOnlyInvolvedTypeIdentifierGenerator).GenerateXml () ) ); XElementComparisonHelper.Compare (output, expectedOutput); }