public static IObjectPersistor CreateObjectPersistor()
        {
            DynamicMock mock = new DynamicMock(typeof(IObjectPersistor));

            mock.SetValue("CollectionFactory", CreateCollectionFactory());

            return (IObjectPersistor)mock.Object;
        }
		public void DisposeTriggerWhenDisposed ()
		{
		    DynamicMock mock = new DynamicMock(typeof(ITrigger));
            ITrigger trigger = (ITrigger) mock.Object;            

            mock.Expect("Dispose");
            AggregatedDeployEventDispatcher dispatcher = new AggregatedDeployEventDispatcher(trigger);
            dispatcher.Dispose();
            mock.Verify();
		}
		public void OnConnectionAddInArgumentExceptionTest()
		{
			DynamicMock mockAddIn = new DynamicMock(typeof(DTE2), "AddIn");

			this.taskList.OnConnection(
				(DTE2)mockAddIn.Object,
				ext_ConnectMode.ext_cm_UISetup,
				new object(),
				ref this.custom
			);
		}
		public void TargetType()
		{
			SideEffectObject target = new SideEffectObject();
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));
			mock.ExpectAndReturn("IsPrototype", true, null);
			mock.ExpectAndReturn("GetType", typeof(SideEffectObject), null);
			PrototypeTargetSource source = new PrototypeTargetSource();
			source.ObjectFactory = (IObjectFactory) mock.Object;
			Assert.AreEqual(target.GetType(), source.TargetType, "Wrong TargetType being returned.");
			mock.Verify();
		}
		public void SetUp()
		{
			_TaskTreeView = new NuGenTaskTreeView();
			_InitialCount = _TaskTreeView.Nodes.Count;
			_EventSink = new TaskTreeViewEventSink(_TaskTreeView);
			_ServiceProvider = new NuGenTaskServiceProvider();
			_XmlDoc = new XmlDocument();

			_TaskItemDescription = "Description";
			_TaskItemMock = new DynamicMock(typeof(TaskItem));
			_TaskItemMock.SetValue("Description", _TaskItemDescription);
			_TaskItem = (TaskItem)_TaskItemMock.Object;

			Assert.IsFalse(_TaskTreeView.LabelEdit);
		}
		public void testIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			IDynamicMock tsControl = new DynamicMock(typeof(ITimeStampedIntroduction));
			ITimeStampedIntroduction ts = (ITimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
	
			tsControl.Verify();
		}
		public void AZSortArgumentNullExceptionOnCollectionTest()
		{
			DynamicMock comparerMock = new DynamicMock(typeof(IComparer<NuGenTreeNode>));
			this.sorter.Sort(null, (IComparer<NuGenTreeNode>)comparerMock.Object);
		}
 public void DisposeDispatcherOnDispose ()
 {
     DynamicMock mock = new DynamicMock (typeof (IDeployEventDispatcher));
     IDeployEventDispatcher dispatcher = (IDeployEventDispatcher) mock.Object;
     mock.Expect ("Dispose");
     IDeployLocation location = new FileSystemDeployLocation (dispatcher, deployPath);
     location.Dispose ();
     mock.Verify ();
 }
 public void SetUp ()
 {
     base.SetUp_();
     factoryMock = new DynamicMock(typeof(IApplicationWatcherFactory));
     watcherMock = new DynamicMock(typeof(IApplicationWatcher));
     factory = (IApplicationWatcherFactory) factoryMock.Object;
     watcher = (IApplicationWatcher) watcherMock.Object;
     deployEventDispatched = false;
     forwardDispatcherSync = new Latch();
 }
        public void ErrorsWhileGettingTheReferenceToTheServiceAreVisibleToTheUser ()
        {
            DynamicMock mockFactory = new DynamicMock(typeof(ISpringServiceFactory));
            DynamicMock mockService = new DynamicMock(typeof(ISpringService));

            mockService.ExpectAndThrow("DeployInformations", new Exception("this and that"));
            mockFactory.ExpectAndReturn("SpringService", mockService.Object);

            monitor.ServiceFactory = mockFactory.Object as ISpringServiceFactory;
            Assert.AreEqual("service not available: this and that", serviceStatus.Text);
            Assert.AreEqual(String.Empty, appStatus.Text);
            ScreenShot ("service not available.gif");
        }
Example #11
0
        public void RemoveAdvisedSupportListener()
        {
            IDynamicMock mock = new DynamicMock(typeof(IAdvisedSupportListener));
            IAdvisedSupportListener listener = (IAdvisedSupportListener)mock.Object;

            ProxyFactory factory = new ProxyFactory(new TestObject());
            factory.AddListener(listener);
            factory.RemoveListener(listener);

            factory.GetProxy();

            // check that no lifecycle callback methods were invoked on the listener...
            mock.Verify();
        }
Example #12
0
        public void AdvisedSupportListenerMethodsAre_NOT_CalledIfProxyHasNotBeenCreated()
        {
            IDynamicMock mock = new DynamicMock(typeof(IAdvisedSupportListener));
            IAdvisedSupportListener listener = (IAdvisedSupportListener)mock.Object;

            ProxyFactory factory = new ProxyFactory(new TestObject());
            factory.AddListener(listener);

            // must not fire the AdviceChanged callback...
            factory.AddAdvice(new NopInterceptor());
            // must not fire the InterfacesChanged callback...
            factory.AddInterface(typeof(ISerializable));

            mock.Verify();
        }
		public void WithNonSingletonTargetObject()
		{
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));
			const string objectName = "Foo";
			mock.ExpectAndReturn("IsPrototype", false, objectName);
			PrototypeTargetSource source = new PrototypeTargetSource();
			source.TargetObjectName = objectName;
			try
			{
				source.ObjectFactory = (IObjectFactory) mock.Object;
				Assert.Fail("Should have thrown an ObjectDefinitionStoreException by this point.");
			}
			catch (ObjectDefinitionStoreException)
			{
				mock.Verify();
			}
		}
		public void GetTarget()
		{
			SideEffectObject target = new SideEffectObject();
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));;
			mock.ExpectAndReturn("IsPrototype", true, "foo");
			mock.ExpectAndReturn("GetObject", target, "foo");
		    mock.ExpectAndReturn("GetType", typeof (string), "foo");
			PrototypeTargetSource source = new PrototypeTargetSource();
            source.TargetObjectName = "foo";
			source.ObjectFactory = (IObjectFactory) mock.Object;
			Assert.IsTrue(object.ReferenceEquals(source.GetTarget(), target),
			              "Initial target source reference not being returned by GetTarget().");
			mock.Verify();
		}
		public void testIntroductionInterceptorWithInterfaceHierarchy() 
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ISubTimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

			IDynamicMock tsControl = new DynamicMock(typeof(ISubTimeStampedIntroduction));
			ISubTimeStampedIntroduction ts = (ISubTimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			// we must add introduction, not an advisor
			factory.AddIntroduction(advisor);

			object proxy = factory.GetProxy();
			ISubTimeStamped tsp = (ISubTimeStamped) proxy;
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);

			tsControl.Verify();
		}
		public void CheckedChangedArgumentNullExceptionOnMenuItemTest()
		{
			DynamicMock groupMock = new DynamicMock(typeof(INuGenMenuItemGroup));
			_checkedTracker.ChangeChecked((INuGenMenuItemGroup)groupMock.Object, null);
		}
Example #17
0
        public void AdvisedSupportListenerMethodsAreCalledAppropriately()
        {
            IDynamicMock mock = new DynamicMock(typeof(IAdvisedSupportListener));
            IAdvisedSupportListener listener = (IAdvisedSupportListener)mock.Object;

            mock.Expect("Activated");
            mock.Expect("AdviceChanged");
            mock.Expect("InterfacesChanged");

            ProxyFactory factory = new ProxyFactory(new TestObject());
            factory.AddListener(listener);

            // must fire the Activated callback...
            factory.GetProxy();
            // must fire the AdviceChanged callback...
            factory.AddAdvice(new NopInterceptor());
            // must fire the InterfacesChanged callback...
            factory.AddInterface(typeof(ISerializable));

            mock.Verify();
        }