This is a migrated thread and some comments may be shown as answers.

JustMock Arrange just stopped working.

3 Answers 293 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
geoff
Top achievements
Rank 1
geoff asked on 24 Jul 2018, 08:48 PM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivo
Telerik team
answered on 26 Jul 2018, 06:25 AM
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
0
geoff
Top achievements
Rank 1
answered on 26 Jul 2018, 04:02 PM
Thanks, that helped! It turns out one of the underlying configurations changed in a pull request.
0
Ivo
Telerik team
answered on 27 Jul 2018, 10:53 AM
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
Tags
General Discussions
Asked by
geoff
Top achievements
Rank 1
Answers by
Ivo
Telerik team
geoff
Top achievements
Rank 1
Share this question
or