public void ChangingDefaultMockObjectFactoryChangesBehaviourOfNewMockeryInstances()
        {
            var mocksA = new Mockery();
            mocksA.SetMockFactoryAs(new TestingMockObjectFactoryA());
            Assert.AreEqual("TestingMockObjectFactoryA", mocksA.NewInstanceOfRole<INamed>().GetName());

            mocksA.SetMockFactoryAs(new TestingMockObjectFactoryB());
            Assert.AreEqual("TestingMockObjectFactoryB", mocksA.NewInstanceOfRole<INamed>().GetName());
        }
 public void SetUp()
 {
     var mockery = new Mockery();
     receiver = mockery.NewInstanceOfRole<IMockObject>(DefinedAs.Named("receiver"));
     invocation = new Invocation(receiver, new MethodInfoStub("method"), new object[] {"arg"});
 }
        public void ByDefaultShouldNotAllowInvocationsFromMultipleThreads()
        {
            mockery = new Mockery();
            var blitzer = new Blitzer(16);
            var numberOfconcurrentExceptions = new AtomicInt(0);
            var mock = mockery.NewInstanceOfRole<ISpeaker>();
            Expect.Exactly(blitzer.TotalActionCount()).On(mock).Message("Hello");
            blitzer.Blitz(() => {
                              try
                              {
                                  mock.Hello();
                              }
                              catch (ConcurrentModificationException)
                              {
                                  numberOfconcurrentExceptions.Increment();
                              }
                          });

            Assert.AreEqual(numberOfconcurrentExceptions.Value, 16, "should intercept invocation from non test thread");
        }