Hi Lior,
I'm not sure if i need to mock the the first call "GetMyRecentProcesses" which is actually what I'm trying to test, to see if it returns all the processes. I just need to fake the httpSessionState being passed into it.
Here's the setup code and part of the test code which I'm using:
[SetUp]
public void SetUp()
{
process = new Process(1);
processVersion = new ProcessVersion(3);
user = new User(25);
user.Processes.Add(process);
user.Save();
processAlert = new ProcessAlert(1);
processInstance = new ProcessInstance(1);
provider = new Provider(1);
provider.PdrProvider.Regions.Add(new ProviderDataRepository.Objects.Region(3));
provider.PdrProvider.Regions.Add(new ProviderDataRepository.Objects.Region(39));
provider.Save();
providerId = provider.Id;
Console.WriteLine("Process count: " + user.Processes.Count);
MockManager.Init();
this.mockHttpSessionState = MockManager.MockObject(typeof(HttpSessionState), Constructor.Mocked);
this.httpSessionState = (HttpSessionState)mockHttpSessionState.Object;
}
[Test]
public void TestGetMyRecentProcesses()
{
Logic.Search.SortOrder sortOrder = new SortOrder(typeof(ProcessInstance), ProcessInstance.Field.StartDate, ODLB.Query.Order.Ascending);
DataTable recentProcesses = new DataTable();
Mock processMock = MockManager.Mock(typeof(ProcessUtility));
processMock.ExpectAndReturn("processQueuedForDeletion", true).Args(process, httpSessionState);
Mock sortMock = MockManager.Mock(typeof(Logic.State.Sorting));
sortMock.ExpectAndReturn("GetSort", sortOrder).Args(httpSessionState, "Active", sortOrder);
DataTable recentProcesses = ProcessInstanceUtility.GetMyRecentProcesses(user, httpSessionState);
Assert.IsNotNull(recentProcesses);
MockManager.Verify();
The HttpSessionState is being used as a parameter in two classes outside of the test case.
The error I get when I run Nunit is the following:
Credentials.Utilities.NUnitTests.ProcessInstanceUtilityTest.TestGetMyRecentProcesses : TypeMock.VerifyException :
TypeMock Verification: Call to Credentials.Utilities.ProcessUtility.processQueuedForDeletion() Parameter: 1
passed object [Credentials.Objects.Process]
is not the same instance as expected [Credentials.Objects.Process]
Thanks,
victoriaBC
________
BMW N45 history