Book Image

Learning F# Functional Data Structures and Algorithms

By : Adnan Masood
Book Image

Learning F# Functional Data Structures and Algorithms

By: Adnan Masood

Overview of this book

Table of Contents (21 chapters)
Learning F# Functional Data Structures and Algorithms
Credits
Foreword
Foreword
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Testing the stack


This is your first introduction to unit testing in F# and requires some familiarity with unit testing frameworks (NUnit, MSTest), as well as NuGet, the .NET Package Manager. You have been working with FSI (FSharp Interactive) within the Visual Studio lately. In this section, we are going to exploit more features of Visual Studio than of REPL.

In order to test the stack methods, Push and Pop, you need to create a test project. Let's first exploit the cross-language functionality provided by MSIL (Microsoft Intermediate Language or IL) and write our first unit tests in C#. Being a member of the .NET family of languages, F#, like C#, and VB.NET, eventually gets translated to IL before it is executed. That is why it is easy to write libraries and classes in any of these languages and use them in others in a seamless manner, most of the time. To demonstrate this, we will use C# and MSTest to write a test case for the stack that we have created in F#.

To write a test case, you...