Quantcast
Channel: Windows 7 Miscellaneous forum
Viewing all articles
Browse latest Browse all 11372

Unit Test for a Static class with static dictionary in C#

$
0
0

I am new to C# UT.

I have static class (requirement are strict).

public static class MyClass
{
public static readonly Dictionary<int, int> MyDictionary;

static MyClass()
{
MyDictionary = new Dictionary<int, int>();
}

public static void init(string filePath)  // external file path which  has key value pair
{
// Fill the dictionary
}

public static int GetValue(int key)
{
int value = -1;
//some conditional logic and then
return MyDictionary.TryGetValue(key, value);
}
}

How to do the unit test for this class and dictionary.


Viewing all articles
Browse latest Browse all 11372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>