I need to test this class:
public abstract class GaBase
{
protected GoogleAnalyticsInfo GAInfo;
protected abstract void PopulateGAInfo();
public string GetGoogleAnalyticsTag()
{
//Return any info related to GAInfo
}
//Some other stuffs
}
I need to unit test the GetGoogleAnalyticsTag
method, but I need to set the property GAInfo
to test it properly. In a production code, we do that using my PopulateGaInfo
method when we derive from this class.
How can I set GAInfo
using stubs?
Here is my test method:
public void MyTest1()
{
var ga = new StubGaBase()
{
PopulateGAInfo01 = () =>
{
// How can I set GAInfo here?
}
};
// The method I need to test
var script = ga.GetGoogleAnalyticsTag();
// My asserts
}