/// <summary> /// Generate the unit test class for a type /// </summary> /// <param name="typeUnderTest">Type to generate unit test from</param> /// <returns>The generated class syntax</returns> public virtual CompilationUnitSyntax GenerateUnitTestClass(Type typeUnderTest) { var assemblyNamespaceName = typeUnderTest.Assembly.GetName().Name; var generatedUnitTestNamespace = $"{assemblyNamespaceName}.Tests{typeUnderTest.Namespace.Replace(assemblyNamespaceName, string.Empty)}"; SetUpUsings(typeUnderTest); var parameters = GetConstructorParameters(typeUnderTest); var fields = _mockGenerator.GenerateFields(typeUnderTest, parameters); var setUp = GenerateSetUp(typeUnderTest, parameters); return(new ClassBuilder($"{typeUnderTest.FormattedClassName()}Tests", generatedUnitTestNamespace) .WithAttributes(new Attribute(ClassAttribute)) .WithUsings(_usings.ToArray()) .WithModifiers(Modifiers.Public) .WithFields(fields.ToArray()) .WithMethods(setUp) .Build()); }