mardi 3 mars 2015

Application variables unit testing using Moq

I am trying to store application variables in my unit test using moq.



[TestMethod]
public void TestGetCompanyList()
{
string applicationValue = "MyConnectionString";
var mockApplication = new Mock<HttpApplicationStateBase>();
mockApplication.SetupSet(s => s["TheConnectionString"] = It.IsAny<string>()).Callback((string name) => applicationValue = (string)val);
mockApplication.SetupGet(s => s["TheconnectionString"]).Returns(() => applicationValue);


var accController = new AccSerController();
CInt cInt = new CInt();
cIn.Iss = "Other";
cIn.Tick = "BK";
var result = accController.GetClist(cIn) as IEnumerable<CList>;
Assert.IsNotNull(result);
}


This is still not working for me, it doesn't use the application variables.


BTW I am following this link: ASP.NET MVC: Unit testing session variables does't change


Aucun commentaire:

Enregistrer un commentaire