public void AddUsings_CodeIsCorrect() { var code = _codeGenerator .AddUsings("System", "System.Text") .Generate(); code.RemoveSpecialCharacters().Should().Be( "using System;" + "using System.Text;"); }
private string GenerateCode() => _codeGenerator .AddUsings(GetReferenceNames()) .AddNamespace(_type.Namespace, nspace => nspace .AddClass($"{_type.Name}Proxy") .WithParent(_type.Name) .WithContent(@class => { @class .AddLine("IDictionary<string, Func<object>> _methods;") .AddLine() .AddConstructor("IDictionary<string, Func<object>> methods", ctor => ctor .AddLine("_methods = methods;")); _mockableMethods.ForEach(methodInfo => @class.AddMethod((MethodInfo)methodInfo, method => method .AddLine($"return ({methodInfo.ReturnType.Name})_methods[\"{methodInfo.Name}\"]();"))); })) .Generate();