This is a migrated thread and some comments may be shown as answers.

Mock.Assert is failing when using arrays inside expression

1 Answer 39 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 05 Jan 2012, 11:49 PM

I have references to arrays inside my Mock.Assert's expression statement which is causing the test to fail.

Here's my test that fails:
[TestMethod]
public void JustMockTest_String_Arrays()
{
    // Arrange
    Mock.SetupStatic(typeof(System.IO.File));
 
    string[] sourceFiles = new string[] { @"X:\source\file1.txt" };
    string[] destinationFiles = new string[] { @"X:\destination\file1.txt" };
 
    // Act
    System.IO.File.Copy(sourceFiles[0], destinationFiles[0]);
 
    // Assert
    Mock.Assert(() => System.IO.File.Copy(sourceFiles[0], destinationFiles[0]), Occurs.Once());
}

Though I noticed if I call the ToString() method, I can get the test to pass:
[TestMethod]
public void JustMockTest_String_Arrays_ToString()
{
    // Arrange
    Mock.SetupStatic(typeof(System.IO.File));
 
    string[] sourceFiles = new string[] { @"X:\source\file1.txt" };
    string[] destinationFiles = new string[] { @"X:\destination\file1.txt" };
 
    // Act
    System.IO.File.Copy(sourceFiles[0], destinationFiles[0]);
 
    // Assert
    Mock.Assert(() => System.IO.File.Copy(sourceFiles[0].ToString(), destinationFiles[0].ToString()), Occurs.Once());
}

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 10 Jan 2012, 10:25 AM
Hi Joel,

Thanks for reporting the problem. I was able to reproduce the bug and it could be an issue with the expression parsing in Mock.Assert. I am creating a PITS entry where you can track the progress of the task and once done you can further create a support ticket where I will send you the updated build.

Here is the PITS task to monitor:
http://www.telerik.com/support/pits.aspx#/public/justmock/9261


Kind Regards,
Mehfuz
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Joel
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or