-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[storage] unit tests/mocks to storage client libraries #6
Comments
We have yet to provide public unit tests as they are currently part of a larger internal testing framework. That being said our tests rely on the public api surface of both the convenience and protocol layers. Your tests should be able to do the same. If there is a specific scenario you are targetting that is not possible via the public api surface, please let us know, joe |
Here is simple test using xunit and moq. [Fact]
public void test()
{
var fakeMsg = new Mock<CloudQueueMessage>();
fakeMsg
.Setup(m => m.Id).Returns("1");
fakeMsg
.Setup(m => m.AsString).Returns("test msg");
var fakeQueue = new Mock<CloudQueue>();
fakeQueue
.Setup(q => q.GetMessage()).Returns(fakeMsg.Object);
var fakeQueueClient = new Mock<CloudQueueClient>();
fakeQueueClient
.Setup(q => q.GetQueueReference("q1")).Returns(fakeQueue.Object);
var queueClient = fakeQueueClient.Object;
var msg = queueClient.GetQueueReference("q1").GetMessage();
Assert.Equal("test msg", msg.AsString);
} And here is the error I get when I run the test. (This is limitation in most mocking frameworks.)
By the way how are guys writing tests and which framework are you using. |
While we dont support mocking in the sense you described above many of our tests are targetted at the storage emulator that ships with the sdk which allows testing without hitting the public cloud. One of the primary reasons the unit tests are not available online is due to the coupling with internal systems. As we continue the effort to provide more open source around the Azure sdks we will be updating these tests. joe |
It would be great to have unit tests even without hitting the storage emulator. |
Absolutely. Again we are in the process of decoupling our tests to be consumable by the public in a simple way. We will update the main branch as soon as this is available. |
+1 on this, bring us IBlobClient and IBlobContainer. Our existing unit tests already want to mock out methods on CloudBlobClient and CloudBlobContainer, and they are resorting to some fairly stupid workarounds in order to do so, like creating wrapper classes. |
(By the way I don't think anyone is asking you to make your unit tests public. They're just asking for you to modify the API to make it easy for us to unit test our consumer code.) |
Yep! +1 to this please. Would really really REALLY love to make it easy to unit test this stuff....
^ That's not so hard to do, for us .. eh MS? *I'm using FakeItEasy for my unit tests. |
Also, should this issue be moved to the Storage repo? |
Updated the generated code to reflect the split files.
Please recreate in https://github.com/Azure/azure-storage-net/. |
Minor change to replace LiveId with MicrosoftId
increasing polling interval to 30 seconds
Adding resourcename and resourcegroup in app.config
* Adding zone support * Adding zone tests * Fixing test name * Adding test recordings * Removing catch all exception from tests, adding comments for the tests we skip * Zone samples * Test recordings for zone samples * Reflecting test name update in recording
Create interface/virtual methods so we can easily write unit tests.
#6
The text was updated successfully, but these errors were encountered: