Ejemplo n.º 1
0
        private static void AssertEqual(ITypeInfo expected, ITypeInfo actual, bool assertProperties)
        {
            var runtimeType = Assert.IsType <RuntimeTypeInfo>(expected);

            var actualFullName = actual.FullName.Replace(
                CompilationUtility.GeneratedAssemblyName,
                runtimeType.TypeInfo.Assembly.GetName().Name);

            Assert.Equal(expected.Name, actual.Name);
#if DNXCORE50
            Assert.Equal(
                RuntimeTypeInfo.SanitizeFullName(expected.FullName),
                RuntimeTypeInfo.SanitizeFullName(actualFullName));
#endif
            Assert.Equal(expected.IsPublic, actual.IsPublic);
            Assert.Equal(expected.IsAbstract, actual.IsAbstract);
            Assert.Equal(expected.IsGenericType, actual.IsGenericType);
            Assert.Equal(
                expected.ImplementsInterface(TagHelperTypeInfo),
                actual.ImplementsInterface(TagHelperTypeInfo));
            Assert.Equal(
                expected.GetGenericDictionaryParameters(),
                actual.GetGenericDictionaryParameters(),
                new DelegateAssertion <ITypeInfo>((x, y) => AssertEqual(x, y, assertProperties: false)));

            if (assertProperties)
            {
                Assert.Equal(
                    expected.Properties.OrderBy(p => p.Name),
                    actual.Properties.OrderBy(p => p.Name),
                    new DelegateAssertion <IPropertyInfo>((x, y) => AssertEqual(x, y)));
            }

            Assert.True(actual.Equals(expected));
            Assert.True(expected.Equals(actual));
            Assert.Equal(expected.GetHashCode(), actual.GetHashCode());
        }