Issue with JustMock Ignoreinstance()

4 posts, 0 answers
  1. Scott
    Scott avatar
    2 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    I'm looking to see what is wrong with this code.  Looking at the samples it should work with the Telerik.JustMock.DLL referenced, but is throwing a build error instead:

    using System;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Telerik.JustMock;

    namespace JustMock_Example
    {
        public class ClassUnderTest
        {
            public bool ReturnsFalse()
            {
                return false;
            }
        }

        [TestClass]
        public class IgnoreInstanceTest
        {
            [TestMethod]
            public void ExampleTest()
            {
                var fake = Mock.Create<ClassUnderTest>();
                Mock.Arrange(() => fake.ReturnsFalse()).Returns(true).IgnoreInstance();

                Assert.IsTrue(new ClassUnderTest().ReturnsFalse());
            }
        }
    }

    ///Throws the following:
    Error 1 'Telerik.JustMock.Expectations.Abstraction.IAssertable' does not contain a definition for 'IgnoreInstance' and no extension method 'IgnoreInstance' accepting a first argument of type 'Telerik.JustMock.Expectations.Abstraction.IAssertable' could be found (are you missing a using directive or an assembly reference?) c:\~\~\documents\visual studio 2010\Projects\JustMock Example\Class1.cs 23 67 JustMock Example

    This is with the most recent build, and hopefully I'm missing something small.
    Thanks!

  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 20 Jun 2012 Link to this post

    Hi Scott,

    Thanks again for sharing the sample. It's the ordering of IgnoreInstance that should be corrected. I wrote the test in the following way and now it works as expected:


    public class ClassUnderTest
    {
        public bool ReturnsFalse()
        {
            return false;
        }
    }
     
    [TestClass]
    public class IgnoreInstanceTest
    {
        [TestMethod]
        public void ExampleTest()
        {
            var fake = Mock.Create<ClassUnderTest>();
            Mock.Arrange(() => fake.ReturnsFalse()).IgnoreInstance().Returns(true);
            Assert.IsTrue(new ClassUnderTest().ReturnsFalse());
        }
    }

     

    Kind Regards,
    Ricky
    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
  4. Scott
    Scott avatar
    2 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2012 Link to this post

    Thanks for the reply Ricky.  The example I got the order of the call from is in the JustMock documentation in the following section: Advanced Usages -> Future Mocking


    var fakeUsed = Mock.Create<UserData>();
    Mock.Arrange(() => fakeUsed.ReturnFive()).Returns(7).IgnoreInstance();

    Assert.AreEqual(7, fakeUsed.ReturnFive());
    Assert.AreEqual(7, new UserData().ReturnFive());  


    Did I find a bug in the documentation?  ;o)


    Thanks again!
  5. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 21 Jun 2012 Link to this post

    Hi Scott,

    Thanks again for pointing the issue to us. I have already notified the team and changes will be applied to the documentation as early as possible.

    I am also adding some points to your telerik account for reporting the same.

    Kind Regards
    Ricky
    the Telerik team

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

Back to Top