The Received.InOrder function is very nice.Using it, this test:--[TestMethod, TestCategory("BVT")] public void TheFileIsEncryptedBeforeItIsSent() {const int encryptFunctionCallOrder = 1; const string encryptFunction = "encrypt"; const int sentFunctionCallOrder = 2; const string sentFunction = "sent"; var expectedFunctionCalls = new SortedList<int, string> { { encryptFunctionCallOrder, encryptFunction }, { sentFunctionCallOrder, sentFunction }, }; var actualFunctionCalls = new SortedList<int, string>(); MockFileEncrypter .When(x => x .Encrypt(Arg.Any<Stream>(), Arg.Any<string>(), Arg.Any<string>())) .Do(x => actualFunctionCalls.Add(encryptFunctionCallOrder, encryptFunction)); MockFileTransferProxy .When(x => x .SendUpload(Arg.Any<string>())) .Do(x => actualFunctionCalls.Add(sentFunctionCallOrder, sentFunction)); ExerciseSut(); actualFunctionCalls .ShouldBeEquivalentTo(expectedFunctionCalls);}
Got collapsed down to:[TestMethod, TestCategory("BVT")] public void TheFileIsEncryptedBeforeItIsSent() { ExerciseSut(); Received.InOrder(() => { MockFileEncrypter.Encrypt(Arg.Any<Stream>(), Arg.Any<string>(), Arg.Any<string>()); MockFileTransferProxy.SendUpload(Arg.Any<string>()); }); }It is much easier to pick out what the test is verifying.
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute...@googlegroups.com.
To post to this group, send email to nsubs...@googlegroups.com.
Visit this group at http://groups.google.com/group/nsubstitute?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.