Showing posts with label moq. Show all posts
Showing posts with label moq. Show all posts

Wednesday, February 16, 2011

Moq Setting local variable using callbacks.

http://code.google.com/p/moq/wiki/QuickStart


// Set up the mock:

AgentLoginParams passedObject = null;

moduleMock.Setup(mm=>mm.Login(It.IsAny())).Callback(alp=> passedObject = alp);

// Do something you’re testing

controller.Login(station, userName, password);

// Assert that something was called with the correct data

Assert.IsNotNull(passedObject);

Assert.AreEqual(userName,passedObject.UserName);