JustMock Arrange just stopped working.

4 posts, 1 answers
  1. geoff
    geoff avatar
    4 posts
    Member since:
    Jun 2017

    Posted 24 Jul 2018 Link to this post

    We use the commercial version of JustMock and are working on a new prototype. Along the way, somehow, my Mock.Arranges for one test class have stopped working.

    These are tests for our Azure KeyVault Wrapper and are super simple.

                IKeyVault keyVault;

                [SetUp]
                public void SetUp()
                {
                    var keyVaultClient = Mock.Create<IKeyVaultClient>();
                    Mock.Arrange(() => keyVaultClient.GetSecretAsync("http://www.myKeyStore.com/Key1", new CancellationToken()))
                        .Returns(Task.FromResult(new SecretBundle { Value = "Secret1" }));

                    Mock.Arrange(() => keyVaultClient.GetSecretAsync("http://www.myKeyStore.com/Key2", new CancellationToken()))
                        .Returns(Task.FromResult(default(SecretBundle)));

                    keyVault = new KeyVault(keyVaultClient);
                }

                [Test]
                public async Task NewSecret_ShouldSucceed()
                {
                    var secret = await keyVault.GetSecretAsync("Key1");

                    Assert.AreEqual("Secret1", secret);
                }

                [Test]
                public async Task ShouldReturnNull_GetSecretAsync()
                {
                    var secret = await keyVault.GetSecretAsync("Key2");

                    Assert.AreEqual(null, secret);
                }

    Both tests are returning SecretBundle objects with all default fields which seems to be an implementation from JustMock (not default(SecretBundle)). Neither have the correct values. The Arrange is simply not working.

    I suspect this has something to do with references no longer being updated from Lite to Commercial, but I have no idea how to update them. The Update Reference button in the JustMock menu doesn't seem to do anything. 

    Any help on how to troubleshoot would be much appreciated. We plan to depend heavily on JustMock for testing this project. Note that these tests, in their current form, were working just fine and the underlying code hasn't changed.

    -Geoff

  2. Answer
    Ivo
    Admin
    Ivo avatar
    21 posts

    Posted 26 Jul 2018 Link to this post

    Hello Geoff,

    I suspect the issue you are facing is due to a failure in arguments matching in the prepared arrangements, that's why the returned value in both cases is just a stubbed one. Since the problem appears without any particular reason, I am suggesting to enable the debug trace which will help to discover the root cause. You can enable tracing by adding the following line at the beginning of your tests:

    DebugView.IsTraceEnabled = true;

    This way you would be able to receive verbose messages in Visual Studio debug output, more details about tracing can be found in this article. Please provide us the content of debug output produced by both tests.

    I hope this information helps.

    Regards,
    Ivo
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. geoff
    geoff avatar
    4 posts
    Member since:
    Jun 2017

    Posted 26 Jul 2018 Link to this post

    Thanks, that helped! It turns out one of the underlying configurations changed in a pull request.
  4. Ivo
    Admin
    Ivo avatar
    21 posts

    Posted 27 Jul 2018 Link to this post

    Hello Geoff,

    I am glad to hear that your issue is now resolved.

    Regards,
    Ivo
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top