public void create_type_with_invalid_header(string header)
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();

            scope.Invoking(sut => sut.CreateType(h => h.Append(header)))
            .Should().Throw <InvalidOperationException>();
        }
        public void TypeDefinitionKey_is_based_only_on_king_and_naked_type_name(string decl, string typeDefinitionKey)
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();
            ITypeScope        type  = scope.CreateType(decl);

            type.Definition.Name.Key.Should().Be(typeDefinitionKey);
        }
        public void creating_existing_type_again_clashes(string original, string clash)
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();

            scope.CreateType(original);
            scope.Invoking(sut => sut.CreateType(clash)).Should().Throw <ArgumentException>();
        }
        public void list_created_types()
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();
            ITypeScope        t1    = scope.CreateType(s => s.Append("public class C1"));
            ITypeScope        t2    = scope.CreateType(s => s.Append("public class C2"));

            scope.Types.Should().BeEquivalentTo(new[] { t1, t2 });
        }
Example #5
0
 /// <summary>
 /// Creates a <see cref="ITypeScope"/> inside this scope.
 /// Its name is automatically extracted from the header that may contain the
 /// opening curly brace '{' or not (in such case it is automatically appended).
 /// </summary>
 /// <param name="this">This scope.</param>
 /// <param name="header">The header of the type. Must not be null.</param>
 /// <returns>The new type scope.</returns>
 public static ITypeScope CreateType(this ITypeDefinerScope @this, string header)
 {
     if (header == null)
     {
         throw new ArgumentNullException(nameof(header));
     }
     return(@this.CreateType(t => t.Append(header)));
 }
        public void creating_type_and_finding_them_back(string decl, string finder)
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();
            ITypeScope        type  = scope.CreateType(decl);

            scope.FindType(finder).Should().BeSameAs(type);

            scope.Invoking(sut => sut.CreateType(decl)).Should().Throw <ArgumentException>();
        }
        public void created_type_has_normalized_Name(string decl, string typeName)
        {
            ITypeDefinerScope scope = CreateTypeDefinerScope();
            ITypeScope        type  = scope.CreateType(h => h.Append(decl));

            type.Name.Should().Be(typeName);
            type.FullName.Should().Be($"{scope.FullName}.{typeName}");

            scope.FindType(typeName).Should().BeSameAs(type);

            scope.Invoking(sut => sut.CreateType(decl)).Should().Throw <ArgumentException>();
        }
 public TypeDefinerPart(ITypeDefinerScope owner)
     : base(owner)
 {
 }