Mock.Assert is failing when using arrays inside expression

2 posts, 0 answers
  1. Joel
    Joel avatar
    19 posts
    Member since:
    Dec 2011

    Posted 05 Jan 2012 Link to this post


    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());
    }

  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 10 Jan 2012 Link to this post

    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 >>

  3. DevCraft R3 2016 release webinar banner
Back to Top