Hi,
I'm trying out some of the new LINQ code and trying to use TypeMock with it. I have 4.1 install. But I keep getting an error.
Error Message
Test method Controller2008.Test.ProductControllerTest.GetCategoriesTest threw exception: TypeMock.TypeMockException:
*** Cannot return a value for ProductsDataContext.get_Categories() because no value was set. use recorder.Return().
*** Note: Cannot mock types from mscorlib assembly..
Unit Test Method
[TestMethod()]
[ClearMocks]
[VerifyMocks]
public void GetCategoriesTest()
{
ProductController target = new ProductController();
List<Category> expected = new List<Category>(){
new Category { CategoryID = 1, CategoryName = "Test1", Description = "Testing1"},
new Category { CategoryID = 2, CategoryName = "Test2", Description = "Testing2"},
new Category { CategoryID = 3, CategoryName = "Test3", Description = "Testing3"}
};
List<Category> actual;
var dummyData = new[] {new { CategoryID = 1, CategoryName = "Test1", Description = "Testing1"},
new { CategoryID = 2, CategoryName = "Test2", Description = "Testing2"},
new { CategoryID = 3, CategoryName = "Test3", Description = "Testing3"}};
ProductsDataContext db = new ProductsDataContext();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
var query = from cat in db.Categories //**Breaks on this line.
select cat;
recorder.Return(dummyData);
}
actual = target.GetCategories();
Assert.AreEqual(expected, actual);
}
Do I need to have the enterprise version to run this code? I'm using the Professional version.
Thanks,
Eric