Sha256: 9216ae62ad717f42c1c684ba234701e64df651857fe196192b51838b85c73a9b
Contents?: true
Size: 1.3 KB
Versions: 65
Compression:
Stored size: 1.3 KB
Contents
using System.Collections.Generic; using System.Linq; using Generators.Methods; namespace Generators.Classes { public static class TestClassRenderer { private const string TestClassTemplate = @"{UsingNamespaces} public class {ClassName} { {Body} }"; public static string Render(TestClass testClass) => TestClassTemplate .Replace("{UsingNamespaces}", RenderUsingNamespaces(testClass)) .Replace("{ClassName}", testClass.ClassName) .Replace("{Body}", RenderBody(testClass)); private static string RenderUsingNamespaces(TestClass testClass) => string.Join("\n", testClass.UsingNamespaces.Select(usingNamespace => $"using {usingNamespace};")); private static string RenderBody(TestClass testClass) => string.Join("\n\n", GetBodyParts(testClass)); private static IEnumerable<string> GetBodyParts(TestClass testClass) => from bodyPart in new [] { testClass.BeforeTestMethods, RenderTestMethods(testClass), testClass.AfterTestMethods } where !string.IsNullOrWhiteSpace(bodyPart) select bodyPart; private static string RenderTestMethods(TestClass testClass) => string.Join("\n\n", testClass.TestMethods.Select(TestMethodRenderer.Render)); } }
Version data entries
65 entries across 65 versions & 1 rubygems