public void GetTypes_FriendlyAssemblyGiven_ShouldReturnInternalTypes() { var assembly = typeof(TestAssembly.AbstractClass).Assembly; testee = AssemblyTraverser.Create(assembly, "UnitTestGenerator.Tests"); var result = testee.GetTypes(); result.Should().Contain(typeof(TestAssembly.InternalClass)); }
public void InternalsVisible_UnfriendlyAssemblyGiven_ShouldReturnFalse() { var assembly = typeof(string).Assembly; string notFriendlyToAssembly = "UnitTestGenerator.Tests"; var result = AssemblyTraverser.InternalsVisible(assembly, notFriendlyToAssembly); result.Should().Be(false); }
public void InternalsVisible_FriendlyAssemblyGiven_ShouldReturnTrue() { var assembly = typeof(TestAssembly.InternalClass).Assembly; string friendlyToAssembly = "UnitTestGenerator.Tests"; var result = AssemblyTraverser.InternalsVisible(assembly, friendlyToAssembly); result.Should().Be(true); }
public void Exclude_TypeGiven_ShouldBeExcluded() { var assembly = typeof(TestAssembly.AbstractClass).Assembly; var typeToExclude = typeof(TestAssembly.ClassContructor); testee = AssemblyTraverser.Create(assembly, "UnitTestGenerator.Tests"); IAssemblyTraverserConfigurator configurator = testee; configurator.Exclude(new[] { typeToExclude }); var result = testee.GetTypes(); result.Should().NotContain(typeToExclude); }
public void GetTypes_UnfriendlyAssemblyGiven_ShouldNotReturnInternalTypes() { var assembly = typeof(TestAssembly.AbstractClass).Assembly; testee = AssemblyTraverser.Create(assembly, "Fake"); var result = testee.GetTypes(); result.Should().Contain(typeof(TestAssembly.PublicClass)); result.Should().NotContain(typeof(TestAssembly.InternalClass)); result.Should().NotContain(typeof(TestAssembly.AbstractClass)); result.Should().NotContain(typeof(TestAssembly.NestedClasses.NestedPublicClass)); result.Should().NotContain(typeof(TestAssembly.GenericClass<>)); }
/// <summary> /// Compose an instance of TestClassBuilder class. /// </summary> /// <param name="assembly">The assembly which types should be used.</param> /// <param name="callingAssemblyName">Name of calling assembly, which is set in <paramref name="assembly"/> in attribute InternalsVisibleTo.</param> /// <param name="typeRegistration">The action where the type registration is set up.</param> /// <param name="configure">The action where the configuration is set up.</param> /// <returns>The instance of <see cref="ITestClassBuilder"/>.</returns> public static ITestClassBuilder ComposeTestClassBuilder(this Assembly assembly, string callingAssemblyName, Action <IContainer> typeRegistration, Action <ITestMethodGeneratorConfigurator> configure = null) { var assemblyTraverser = AssemblyTraverser.Create(assembly, callingAssemblyName); var generatorRegistrationManager = new GeneratorRegistrationManager(); var testGeneratorConfigurator = new TestMethodGeneratorConfigurator(assemblyTraverser, generatorRegistrationManager); var setup = new TestMethodGeneratorComposition(assemblyTraverser, testGeneratorConfigurator, generatorRegistrationManager); var testGenerators = setup.GetGenerators(typeRegistration, configure); return(new TestClassBuilder(assemblyTraverser, testGenerators)); }
public void GetTypes_UnfriendlyAssemblyGiven_ShouldNotReturnInternalTypes() { var assembly = typeof(TestAssembly.AbstractClass).Assembly; testee = AssemblyTraverser.Create(assembly, "Fake"); var result = testee.GetTypes(); result.Should().Contain(typeof(TestAssembly.PublicClass)); result.Should().NotContain(typeof(TestAssembly.InternalClass)); result.Should().NotContain(typeof(TestAssembly.AbstractClass)); result.Should().NotContain(typeof(TestAssembly.NestedClasses.NestedPublicClass)); result.Should().NotContain(typeof(TestAssembly.GenericClass <>)); }
public void Initialize() { testee = AssemblyTraverser.Create(typeof(AssemblyTraverser).Assembly, typeof(AssemblyTraverserTests).Assembly.GetName().Name); }
public void InternalsVisible_CallingAssemblyNameNullValueGiven_ShouldThrowArgumentNullException() { AssemblyTraverser.InternalsVisible(typeof(string).Assembly, null); }
public void InternalsVisible_TargetAssemblyNullValueGiven_ShouldThrowArgumentNullException() { AssemblyTraverser.InternalsVisible(null, Value.Create <string>()); }
public void Create_CallingAssemblyNameNullValueGiven_ShouldThrowArgumentNullException() { AssemblyTraverser.Create(typeof(string).Assembly, null); }
public TestMethodGeneratorConfigurator(AssemblyTraverser traverser, GeneratorRegistrationManager generatorManager) { this.traverser = traverser; this.generatorManager = generatorManager; }