Пример #1
0
        public void MyTestCleanup()
        {
            PrivateType privateWindowType = new PrivateType(typeof(VSWindows));
            privateWindowType.SetStaticFieldOrProperty("instance", null);

            this.serviceProvider = null;
        }
Пример #2
0
 public void VsAnalysisHelperConstructorTest()
 {
     IServiceProvider serviceProvider = new MockServiceProvider();
     StyleCopCore core = new StyleCopCore();
     FileAnalysisHelper_Accessor specificTarget = new FileAnalysisHelper_Accessor(serviceProvider, core);
     AnalysisHelper_Accessor target = FileAnalysisHelper_Accessor.AttachShadow(specificTarget.Target);
     Assert.IsNotNull(target, "Unable to instantiate the AnalysisHelper class");
     Assert.IsNotNull(target.Core, "AnalysisHelper.Core was null");
 }
Пример #3
0
        public void EventsCookieTest()
        {
            var serviceProvider = new MockServiceProvider();
            SolutionListener_Accessor target = new SolutionListener_Accessor(serviceProvider);
            uint expected = 0;

            uint actual = target.eventsCookie;
            Assert.AreEqual(expected, actual, "initial value should be zero");

            target.Initialize();

            actual = target.eventsCookie;
            Assert.IsTrue(expected < actual, "Value after initialize should not be zero.");
        }
Пример #4
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_Accessor target = new SolutionListener_Accessor(serviceProvider);
            target.eventsCookie = cookie;
            target.Dispose();

            uint expected = 0;
            Assert.AreEqual(expected, target.eventsCookie, "Dispose does not remove the event sink");
        }
        public void AnalysisHelperConstructorTest()
        {
            try
            {
                IServiceProvider serviceProvider = new MockServiceProvider();
                StyleCopCore core = new StyleCopCore();
                FileAnalysisHelper specificTarget = new FileAnalysisHelper(serviceProvider, core);

                Assert.IsNotNull(specificTarget, "Unable to instantiate the AnalysisHelper class");
                Assert.IsNotNull(specificTarget.Core, "AnalysisHelper.Core was null");
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
        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.");
        }
        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.");
        }
        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");
        }
        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);
            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");
        }
        public void DisposeTest()
        {
            var serviceProvider = new MockServiceProvider();
            var mockUpdateSolutionEvents = new Mock<IVsUpdateSolutionEvents>();
            UpdateSolutionListener target = new UpdateSolutionListener(serviceProvider);

            uint cookie = 0;
            ((IVsSolutionBuildManager)serviceProvider.GetService(typeof(SVsSolutionBuildManager))).AdviseUpdateSolutionEvents(mockUpdateSolutionEvents.Instance as IVsUpdateSolutionEvents, out cookie);
            Debug.Assert(cookie == 1);

            bool disposing = true;

            PrivateObject updateSolutionListner = new PrivateObject(target, new PrivateType(typeof(UpdateSolutionListener)));
            updateSolutionListner.SetFieldOrProperty("eventsCookie", cookie);
            updateSolutionListner.Invoke("Dispose", disposing);
        }
        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");
        }
        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"));
        }
 private IServiceProvider PrepareServiceProvider()
 {
     var mock = new MockServiceProvider();
     return mock;
 }
        public void DisposeTest()
        {
            try
            {
                var serviceProvider = new MockServiceProvider();
                var mockUpdateSolutionEvents = new Mock<IVsUpdateSolutionEvents>();
                UpdateSolutionListener target = new UpdateSolutionListener(serviceProvider);

                uint cookie = 0;
                ((IVsSolutionBuildManager)serviceProvider.GetService(typeof(SVsSolutionBuildManager))).AdviseUpdateSolutionEvents(mockUpdateSolutionEvents.Instance as IVsUpdateSolutionEvents, out cookie);
                Debug.Assert(cookie == 1);

                bool disposing = true;

                PrivateObject updateSolutionListner = new PrivateObject(target, new PrivateType(typeof(UpdateSolutionListener)));
                updateSolutionListner.SetFieldOrProperty("eventsCookie", cookie);
                updateSolutionListner.Invoke("Dispose", disposing);
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
        public void InitializeTest()
        {
            try
            {
                var serviceProvider = new MockServiceProvider();

                UpdateSolutionListener target = new UpdateSolutionListener(serviceProvider);
                target.Initialize();

                PrivateObject updateSolutionListener = new PrivateObject(target, new PrivateType(typeof(UpdateSolutionListener)));

                uint expected = 1;
                Assert.AreEqual(expected, updateSolutionListener.GetFieldOrProperty("eventsCookie"));
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
        public void DisposeTest()
        {
            var serviceProvider = new MockServiceProvider();
            var mockUpdateSolutionEvents = new Mock<IVsUpdateSolutionEvents>();
            UpdateSolutionListener target = new UpdateSolutionListener(serviceProvider);

            uint cookie = 0;
            ((IVsSolutionBuildManager)serviceProvider.GetService(typeof(SVsSolutionBuildManager))).AdviseUpdateSolutionEvents(mockUpdateSolutionEvents.Instance as IVsUpdateSolutionEvents, out cookie);
            Debug.Assert(cookie == 1);

            target.GetType()
                .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                .SetValue(target, cookie);
            target.Dispose();
        }
        public void InitializeTest()
        {
            var serviceProvider = new MockServiceProvider();

            UpdateSolutionListener target = new UpdateSolutionListener(serviceProvider); 
            target.Initialize();

            uint expected = 1;
            Assert.AreEqual(expected, expected, (uint)target.GetType()
                .GetField("eventsCookie", BindingFlags.Instance | BindingFlags.NonPublic)
                .GetValue(target));
        }
 public void MyTestCleanup()
 {
     this.serviceProvider = null;
     typeof(VSWindows).GetField("instance", BindingFlags.Static | BindingFlags.NonPublic)
         .SetValue(null, null);
 }
Пример #19
0
        public void InitializeTest()
        {
            var serviceProvider = new MockServiceProvider();
            SolutionListener_Accessor target = new SolutionListener_Accessor(serviceProvider);
            uint expected = 0;
            Assert.AreEqual(expected, target.eventsCookie);

            expected = 1;
            target.eventsCookie = expected;
            target.Initialize();
            Assert.AreEqual(expected, target.eventsCookie);
        }
Пример #20
0
 public void MyTestCleanup()
 {
     this.serviceProvider = null;
     VSWindows_Accessor.instance = null;
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     serviceProvider = new MockServiceProvider();
 }
        public void DisposeTest()
        {
            var serviceProvider = new MockServiceProvider();
            var mockUpdateSolutionEvents = new Mock<IVsUpdateSolutionEvents>();
            UpdateSolutionListener_Accessor target = new UpdateSolutionListener_Accessor(serviceProvider);

            uint cookie = 0;
            ((IVsSolutionBuildManager)serviceProvider.GetService(typeof(SVsSolutionBuildManager))).AdviseUpdateSolutionEvents(mockUpdateSolutionEvents.Instance as IVsUpdateSolutionEvents, out cookie);
            Debug.Assert(cookie == 1);

            bool disposing = true;
            target.eventsCookie = cookie;
            target.Dispose(disposing);
        }
 public void MyTestInitialize()
 {
     this.serviceProvider = new MockServiceProvider();
 }
Пример #24
0
 public void TestInitialize()
 {
     this.mockServiceProvider = new MockServiceProvider();
     this.serviceProvider = this.mockServiceProvider;
     ProjectUtilities_Accessor.serviceProvider = this.serviceProvider;
 }