This is a migrated thread and some comments may be shown as answers.
Test passes via XUnit but not in Visual Studio
2 Answers 32 Views
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Al asked on 06 Apr 2012, 03:00 PM
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 Answers, 1 is accepted

Sort by
0
Al
Top achievements
Rank 1
answered on 06 Apr 2012, 04:05 PM
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.
0
Accepted
Ricky
Telerik team
answered on 10 Apr 2012, 08:28 PM
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 >>

Asked by
Al
Top achievements
Rank 1
Answers by
Al
Top achievements
Rank 1
Ricky
Telerik team
Share this question
or