public void UsingAFSharpModuleDirectly() { // Using two module functions (like a C# static class to build the list) var list = RecursiveList.cons("TEST", RecursiveList.EmptyList <string>()); // Building a discriminated union the C# way to assert equality var expectedList = RecursiveList <string> .NewHead("TEST", RecursiveList.EmptyList <string>()); Assert.AreEqual(expectedList, list); }
public void UsingCSharpFriendlyApiInsteadOfFSharpFunc() { // These are all using the module functions. // Module is just a static class to C#. var list = RecursiveList.EmptyList <string>(); var listWithAddedData = RecursiveList.cons("Test", list); Func <string, string> mapFunction = s => "TEST3" + s; var mappedList = listWithAddedData.Select(mapFunction); var expectedList = RecursiveList <string> .NewHead("TEST3Test", RecursiveList <string> .Empty); Assert.AreEqual(expectedList, mappedList); }
public void UsingFSharpFuncIfYouHaveTo() { // These are all using the module functions. // Module is just a static class to C#. var list = RecursiveList.EmptyList <string>(); var listWithAddedData = RecursiveList.cons("Test", list); Func <string, string> mapFunction = s => "TEST2" + s; var fsharpFunc = mapFunction.ToFSharpFunc(); var mappedList = RecursiveList.map(fsharpFunc, listWithAddedData); var expectedList = RecursiveList <string> .NewHead("TEST2Test", RecursiveList <string> .Empty); Assert.AreEqual(expectedList, mappedList); }