Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xunit3TypeInfo"/> class.
        /// </summary>
        /// <param name="v2TypeInfo">The v2 type info to wrap.</param>
        public Xunit3TypeInfo(ITypeInfo v2TypeInfo)
        {
            V2TypeInfo = Guard.ArgumentNotNull(v2TypeInfo);

            Assembly   = new Xunit3AssemblyInfo(V2TypeInfo.Assembly);
            BaseType   = V2TypeInfo.BaseType == null ? null : new Xunit3TypeInfo(v2TypeInfo.BaseType);
            Interfaces = V2TypeInfo.Interfaces.Select(i => new Xunit3TypeInfo(i)).CastOrToReadOnlyCollection();

            var typeName     = V2TypeInfo.Name;
            var namespaceIdx = typeName.LastIndexOf('.');

            if (namespaceIdx < 0)
            {
                SimpleName = typeName;
            }
            else
            {
                Namespace  = typeName.Substring(0, namespaceIdx);
                SimpleName = typeName.Substring(namespaceIdx + 1);

                var innerClassIdx = SimpleName.LastIndexOf('+');
                if (innerClassIdx >= 0)
                {
                    SimpleName = SimpleName.Substring(innerClassIdx + 1);
                }
            }
        }