Ejemplo n.º 1
0
        public void SolutionListenerConstructorTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);

            Assert.IsNotNull(target);
        }
Ejemplo n.º 2
0
        public void SolutionTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            IVsSolution      actual          = (IVsSolution)typeof(SolutionListener)
                                               .GetField("solution", BindingFlags.Instance | BindingFlags.NonPublic)
                                               .GetValue(target);

            Assert.IsNotNull(actual, "Cnstructor did not get the solution class.");
        }
Ejemplo n.º 3
0
        public void OnBeforeOpeningChildrenTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            IVsHierarchy     hierarchy       = null; // TODO: Initialize to an appropriate value
            int expected = VSConstants.E_NOTIMPL;
            int actual;

            actual = target.OnBeforeOpeningChildren(hierarchy);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void OnAfterMergeSolutionTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            object           pUnkReserved    = null; // TODO: Initialize to an appropriate value
            int expected = VSConstants.E_NOTIMPL;
            int actual;

            actual = target.OnAfterMergeSolution(pUnkReserved);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void SolutionTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);

            PrivateObject solutionListner = new PrivateObject(target, new PrivateType(typeof(SolutionListener)));

            IVsSolution actual = (IVsSolution)solutionListner.GetFieldOrProperty("solution");

            Assert.IsNotNull(actual, "Cnstructor did not get the solution class.");
        }
Ejemplo n.º 6
0
        public void OnBeforeUnloadProjectTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            IVsHierarchy     pRealHierarchy  = null; // TODO: Initialize to an appropriate value
            IVsHierarchy     pStubHierarchy  = null; // TODO: Initialize to an appropriate value
            int expected = VSConstants.E_NOTIMPL;
            int actual;

            actual = target.OnBeforeUnloadProject(pRealHierarchy, pStubHierarchy);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void OnAfterOpenProjectTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            IVsHierarchy     hierarchy       = null; // TODO: Initialize to an appropriate value
            int fAdded   = 0;                        // TODO: Initialize to an appropriate value
            int expected = VSConstants.E_NOTIMPL;
            int actual;

            actual = target.OnAfterOpenProject(hierarchy, fAdded);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void OnAfterOpenSolutionTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);

            bool eventFired = false;

            target.AfterSolutionOpened += (sender, args) => { eventFired = true; };
            int expected = VSConstants.S_OK;
            int actual   = target.OnAfterOpenSolution(null, 0);

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(eventFired, "Event was not fired");
        }
Ejemplo n.º 9
0
        public void OnQueryCloseProjectTest()
        {
            IServiceProvider serviceProvider = this.PrepareServiceProvider();
            SolutionListener target          = new SolutionListener(serviceProvider);
            IVsHierarchy     hierarchy       = null; // TODO: Initialize to an appropriate value
            int fRemoving        = 0;                // TODO: Initialize to an appropriate value
            int pfCancel         = 0;                // TODO: Initialize to an appropriate value
            int pfCancelExpected = 0;                // TODO: Initialize to an appropriate value
            int expected         = VSConstants.E_NOTIMPL;
            int actual;

            actual = target.OnQueryCloseProject(hierarchy, fRemoving, ref pfCancel);
            Assert.AreEqual(pfCancelExpected, pfCancel);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
        public void OnBeforeCloseSolutionTest()
        {
            var serviceProvider = new MockServiceProvider();

            SolutionListener target = new SolutionListener(serviceProvider);

            bool eventFired = false;

            target.BeforeClosingSolution += (sender, args) => { eventFired = true; };
            int expected = VSConstants.S_OK;
            int actual   = target.OnBeforeCloseSolution(null);

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(eventFired, "Event was not fired");
        }
Ejemplo n.º 11
0
        public void InitializeTest()
        {
            var serviceProvider       = new MockServiceProvider();
            SolutionListener target   = new SolutionListener(serviceProvider);
            uint             expected = 0;

            PrivateObject solutionListner = new PrivateObject(target, new PrivateType(typeof(SolutionListener)));

            Assert.AreEqual(expected, solutionListner.GetFieldOrProperty("eventsCookie"));

            expected = 1;
            solutionListner.SetFieldOrProperty("eventsCookie", expected);
            target.Initialize();
            Assert.AreEqual(expected, solutionListner.GetFieldOrProperty("eventsCookie"));
        }
Ejemplo n.º 12
0
        public void InitializeTest()
        {
            var serviceProvider       = new MockServiceProvider();
            SolutionListener target   = new SolutionListener(serviceProvider);
            uint             expected = 0;

            Assert.AreEqual(expected, (uint)typeof(SolutionListener)
                            .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                            .GetValue(target));

            expected = 1;
            typeof(SolutionListener).GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(target, expected);
            target.Initialize();
            Assert.AreEqual(expected, (uint)typeof(SolutionListener)
                            .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                            .GetValue(target));
        }
Ejemplo n.º 13
0
        public void EventsCookieTest()
        {
            var serviceProvider       = new MockServiceProvider();
            SolutionListener target   = new SolutionListener(serviceProvider);
            uint             expected = 0;

            uint actual = (uint)typeof(SolutionListener)
                          .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                          .GetValue(target);

            Assert.AreEqual(expected, actual, "initial value should be zero");

            target.Initialize();

            actual = (uint)typeof(SolutionListener)
                     .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                     .GetValue(target);
            Assert.IsTrue(expected < actual, "Value after initialize should not be zero.");
        }
Ejemplo n.º 14
0
        public void EventsCookieTest()
        {
            var serviceProvider       = new MockServiceProvider();
            SolutionListener target   = new SolutionListener(serviceProvider);
            uint             expected = 0;


            PrivateObject solutionListner = new PrivateObject(target, new PrivateType(typeof(SolutionListener)));


            uint actual = (uint)solutionListner.GetFieldOrProperty("eventsCookie");

            Assert.AreEqual(expected, actual, "initial value should be zero");

            target.Initialize();

            actual = (uint)solutionListner.GetFieldOrProperty("eventsCookie");
            Assert.IsTrue(expected < actual, "Value after initialize should not be zero.");
        }
Ejemplo n.º 15
0
        public void DisposeTest()
        {
            var serviceProvider    = new MockServiceProvider();
            var mockSolutionEvents = new Mock <IVsSolutionEvents>();

            uint cookie = 0;

            ((IVsSolution)serviceProvider.GetService(typeof(SVsSolution))).AdviseSolutionEvents(mockSolutionEvents.Instance as IVsSolutionEvents, out cookie);
            Debug.Assert(cookie == 1);

            SolutionListener target = new SolutionListener(serviceProvider);

            PrivateObject solutionListner = new PrivateObject(target, new PrivateType(typeof(SolutionListener)));

            solutionListner.SetFieldOrProperty("eventsCookie", cookie);
            target.Dispose();

            uint expected = 0;

            Assert.AreEqual(expected, solutionListner.GetFieldOrProperty("eventsCookie"), "Dispose does not remove the event sink");
        }
Ejemplo n.º 16
0
        public void DisposeTest()
        {
            var serviceProvider    = new MockServiceProvider();
            var mockSolutionEvents = new Mock <IVsSolutionEvents>(MockBehavior.Strict);

            uint cookie = 0;

            ((IVsSolution)serviceProvider.GetService(typeof(SVsSolution))).AdviseSolutionEvents(mockSolutionEvents.Object, out cookie);
            Debug.Assert(cookie == 1);

            SolutionListener target = new SolutionListener(serviceProvider);

            typeof(SolutionListener).GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(target, cookie);
            target.Dispose();

            uint expected = 0;

            Assert.AreEqual(expected,
                            typeof(SolutionListener).GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                            .GetValue(target), "Dispose does not remove the event sink");
        }