public void Complains_about_unmet_expectations_after_timeout() { AutoMockPlug autoPlug = MockPlug.Register(new XUri("http://auto/plug")); autoPlug.Expect("POST", new XUri("http://auto/plug/a")); autoPlug.Expect("PUT", new XUri("http://auto/plug/b"), new XDoc("foo")); Assert.IsFalse(autoPlug.WaitAndVerify(TimeSpan.FromSeconds(1)), autoPlug.VerificationFailure); autoPlug.Reset(); autoPlug.Expect("POST", new XUri("http://auto/plug/a")); autoPlug.Expect("PUT", new XUri("http://auto/plug/b"), new XDoc("foo")); Async.Fork(() => Plug.New("http://auto/plug/a").Post(), new Result()); Assert.IsFalse(autoPlug.WaitAndVerify(TimeSpan.FromSeconds(1)), autoPlug.VerificationFailure); Assert.AreEqual(1, autoPlug.MetExpectationCount); }
public void Waits_until_expectations_are_met_after_each_reset() { AutoMockPlug autoPlug = MockPlug.Register(new XUri("http://auto/plug")); autoPlug.Expect("POST", new XUri("http://auto/plug/a")); autoPlug.Expect("PUT", new XUri("http://auto/plug/b"), new XDoc("foo")); Async.Fork(() => { Plug.New("http://auto/plug/a").Post(); Plug.New("http://auto/plug/b").Put(new XDoc("foo")); }, new Result()); Assert.IsTrue(autoPlug.WaitAndVerify(TimeSpan.FromSeconds(2)), autoPlug.VerificationFailure); autoPlug.Reset(); autoPlug.Expect("GET", new XUri("http://auto/plug/c")); autoPlug.Expect("GET", new XUri("http://auto/plug/d")); Async.Fork(() => { Plug.New("http://auto/plug/c").Get(); Plug.New("http://auto/plug/d").Get(); }, new Result()); Assert.IsTrue(autoPlug.WaitAndVerify(TimeSpan.FromSeconds(2)), autoPlug.VerificationFailure); }