private static void CreateTest(CodeBlock c, string permutation, string sourceSymbols) { var code = c.Code; c.WriteLine("[Test]"); var initValue = GetRandomInitValue(sourceSymbols); using (var m = Block("public void " + permutation + "_Definition()", code)) { m.WriteLine("var value = new Vector" + sourceSymbols.Length + "(" + string.Join(",", initValue) + ");"); m.WriteLine(GetExpectedLine(permutation, sourceSymbols, initValue)); m.WriteLine("Assert.AreEqual(expected, value." + permutation + "());"); } }
private static void CreateImplementation(CodeBlock c, string permutation, string sourceSymbols) { var code = c.Code; int outSize = permutation.Length; int inSize = sourceSymbols.Length; string[] components = permutation.Select(symbol => string.Concat("v.", char.ToLower(symbol))).ToArray(); string docSourceVec = string.Join(",", sourceSymbols.Select(s => s.ToString()).ToArray()); string docPermVec = string.Join(",", permutation.Select(s => s.ToString()).ToArray()); c.WriteLine("///<summary>"); c.WriteLine("/// Give a vector (" + docSourceVec + ") returns a vector (" + docPermVec + ")"); c.WriteLine("///</summary>"); using (var m = Block("public static Vector" + outSize + " " + permutation + "(this Vector" + inSize + " v)", code)) { m.WriteLine("return new Vector" + outSize + "(" + string.Join(",", components) + ");"); } }