Test passes via XUnit but not in Visual Studio

3 posts, 1 answers
  1. Al
    Al avatar
    5 posts
    Member since:
    Apr 2012

    Posted 06 Apr 2012 Link to this post

    Environment:
    OS: Windows 7 Enterprise 64-bit
    IDE: Visual Studio 2010 Premium
    JustMocks: "Trial Version Q1 2012 Visual Studio 11 Refresh - Build (2012.1.229.0)"

    I have a Enabled JustMock in Visual Studio 2010 and am attempting to run the following test against SharePoints SPWebApplication:
    [TestMethod]
    [TestCategory("JustMocked")]
    public void ValidSPWebApp_SetsEmailAddresses_JustMocked()
    {
        var fakeSPWebApp = Mock.Create<SPWebApplication>(Constructor.Mocked);
        Mock.Arrange(() => fakeSPWebApp.OutboundMailServiceInstance.Server.Address).Returns(SmtpHostName);
        Mock.Arrange(() => fakeSPWebApp.OutboundMailSenderAddress).Returns(EmailAddressForSender);
        Mock.Arrange(() => fakeSPWebApp.OutboundMailReplyToAddress).Returns(EmailAddressForReplyTo);
     
        var sut = new SimpleEmailHelper(fakeSPWebApp);
        Assert.AreEqual(EmailAddressForSender, sut.SenderMailAddress.Address);
        Assert.AreEqual(EmailAddressForReplyTo, sut.ReplyToAddress.Address);
    }

    I get the following exception message:
    Telerik.JustMock.MockException: There were some problems intercepting the mock call. Optionally, please make sure that you have turned on JustMock's profiler while mocking concrete members.

    When I run it via the xUnit GUI Runner it passes. I use the following command to run xUnit via an external tool in VS:

    JustMockRunner.exe xunit.gui.clr4.exe $(BinDir)$(TargetName)$(TargetExt)

    and here is the xUnit version of the test:
    [Fact]
    [Trait("Tag", "JustMocked")]
    public void ValidSPWebApp_SetsEmailAddresses_JustMocked()
    {
        var fakeSPWebApp = Mock.Create<SPWebApplication>();
        Mock.Arrange(() => fakeSPWebApp.OutboundMailServiceInstance.Server.Address).Returns(SmtpHostName);
        Mock.Arrange(() => fakeSPWebApp.OutboundMailSenderAddress).Returns(EmailAddressForSender);
        Mock.Arrange(() => fakeSPWebApp.OutboundMailReplyToAddress).Returns(EmailAddressForReplyTo);
     
        var sut = new SimpleEmailHelper(fakeSPWebApp);
        Assert.Equal(EmailAddressForSender, sut.SenderMailAddress.Address);
        Assert.Equal(EmailAddressForReplyTo, sut.ReplyToAddress.Address);
    }

    Any ideas would be appreciated.
  2. Al
    Al avatar
    5 posts
    Member since:
    Apr 2012

    Posted 06 Apr 2012 Link to this post

    Sorry, it is now working.

    Apparently there was a conflict between JustMock and another mocking tool I was evaluating. I disabled the other tools VS Extensions and the test now runs fine.
  3. DevCraft R3 2016 release webinar banner
  4. Answer
    Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 10 Apr 2012 Link to this post

    Hi Gonzalez,

    It's great that the issue is resolved at your end. However if you have any other questions or found some specific issues, feel free to write us back.


    Kind regards,
    Mehfuz
    the Telerik team

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

Back to Top