c# - Need to control order of method expectation based on the expectation of a property being set -
I have the following example that I hope the way I do not expect.
public abstract class example {public essence string Foo (); Public listing & lt; String & gt; Bar () {pre-system (); Var list = new list & lt; String & gt; (); Var stack = new stack & lt; String & gt; (); Foreach (different items in start) {stack.Push (item); } While (Stack. Any) {SomeThing = stack.Pop (); Var f = Foo (); List.Add (f); } Postmath (); Return list; } Public abstract zero pre-method (); Public essence zero postmeth (); Public abstract IEnumerable & lt; String & gt; Stuff {get; } Setting the public essence string someThing { get; }} [Test class] public class ExampleTest {personal example Example; Private Mock Repository Mock; [Test Initiative] Public Zero Initial Test () {Mock = New Mok Repository (); Example = Mock Ritzitri GeneratePartialMock & lt; Example & gt; (); } [TestMethod] Public Zero Barts () {usage (mocks.Ordered ()) {example.Expect (e => E. Premith ()); For example (A = & gt; E.St.F.). Return (new [] {"one", "two"}); (Using mocks.Unordered ()) using (mocks.Unordered ()) {example.expt (E => E. soming). Settropetida with agreement ("One"); Example (A = & gt; E.F.U.) Return ("A"); } (Mocks.Ordered ()) {example.Expect (e = & gt; e.SomeThing). SETPropertyWithArgument ("Two"); Example (E = & gt; E.F.U.) Return ("two"); }} Example.Expect (e = & gt; e.PostMethod ()); } Mocks.ReplayAll (); Var real = example.bar (); Assure. First (2, real.account); Decide. First ("two", actual [0]); Decide. First ("one", actual [1]); }} So, it is expected that the call by using some and Foo by using (mocks. will return the value based on that foo that some was set up now, but the exam failed because the resultant list actually contained "one ", Then" two ". When I debug, I think that after some , "two" calls are returned to "<"> "one". Actually I just want to return to Foo that it was linked to some , but without knowing that they will be set (basically this test should be done)
So the first thing I know is that the order does not work with AAA style second I know I see what I can get by using the when called . Law Public Zero Baraste (example). Example (E => E. Premith ()); For example (A = & gt; E.St.F.). Return (new [] {"one", "two"}); Example (A = & gt; E. Soothing). Setup Contrast with Astrum ("A"). When Called (oz => Example Expect (E = & gt; EFU). Return ("One" )); Example (A = & gt; E. Soothing). Setup Pottery with Agreement ("Two"). When Called (oz = = example.expt (E => E.F.U.). Return ("Two") ); for example. (A = & gt; E. Postmath ()); Var real = example.bar (); Assurance Requel (2, real.account); Decide. First ("two", actual [0]); Decide. First ("one", actual [1]); Example.VerifyAllExpectations (); } By entering expectations within when called , it ensures that there is hope in the expected order.
Comments
Post a Comment