예제 #1
0
        public void Deregister_allows_reregister_of_uri()
        {
            XUri uri         = new XUri("http://www.mindtouch.com/foo");
            int  firstCalled = 0;

            MockPlug.Register(uri, delegate(Plug p, string v, XUri u, DreamMessage r, Result <DreamMessage> r2) {
                firstCalled++;
                r2.Return(DreamMessage.Ok());
            });
            Assert.IsTrue(Plug.New(uri).GetAsync().Wait().IsSuccessful);
            Assert.AreEqual(1, firstCalled);
            MockPlug.Deregister(uri);
            int secondCalled = 0;

            MockPlug.Register(uri, delegate(Plug p, string v, XUri u, DreamMessage r, Result <DreamMessage> r2) {
                secondCalled++;
                r2.Return(DreamMessage.Ok());
            });
            Assert.IsTrue(Plug.New(uri).GetAsync().Wait().IsSuccessful);
            Assert.AreEqual(1, firstCalled);
            Assert.AreEqual(1, secondCalled);
        }