Thanks for your response. I have serveral questions about your response?
I dont folow you when you say:
This sort of an exception is received in Sharepoint unit test projects where you miss a dependency to isolate, and an original implementation of Sharepoint code tries to execute.
What means that?. I added the [Isolated] Attribute if is what you mean?.
But It didn´t work.
This is not the test that I really want to test but, I comment everyting in order to reduce my test and see if I can make to work.
I already try to add assembly reference from my disk alocation, was my first test. But nothing did work!. Y almost try with your code sample:
[TestMethod,Isolated]
public void RepositoryAdd_FakeSPServer_PropertiesAreSetWithCorrectArguments() {
var fakeWeb = Isolate.Fake.Instance<SPWeb>(Members.ReturnRecursiveFakes);
var fakeUser = fakeWeb.SiteUsers.GetByID(1);
var fakeItem = fakeWeb.Lists[""].Items.Add();
Isolate.WhenCalled(() => fakeItem[0]).WillReturn(1);
//Registration registration = new Registration() { CourseId = 1234, RegistrationStatus = "Pending", Title = "UnitTest", UserId = 100 };
//RegistrationRepository repository = new RegistrationRepository();
//int id = repository.Add(registration, false, fakeWeb);
Assert.AreEqual(1, fakeItem.ID);
//Isolate.Verify.WasCalledWithExactArguments(() => fakeItem[Fields.Title] = "UnitTest");
//Isolate.Verify.WasCalledWithExactArguments(() => fakeItem[Fields.UserId] = 100);
//Isolate.Verify.WasCalledWithExactArguments(() => fakeItem[Fields.User] = fakeUser);
//Isolate.Verify.WasCalledWithExactArguments(() => fakeItem[Fields.Status] = "Pending");
}
but it did not work too!. How I said first, It works in a server installation. But not from my developer machine in Vista with SP2.
Installed. I read docs in microsoft and some folks mention that Testing sharePoint needs to be run in server that it has installed
SharePoint Server. So I don't know if I'm missing some configuration. I disable the ACL in Vista. But nothing change. I run VS2008 as Administrator but nothing!.