public void InitializeServicesResolvesViewModelServiceInstance()
        {
            // Arrange

            var serviceResolved = false;

            var package = new WorkingFilesWindowPackage();
            var kernel  = new MoqMockingKernel();

            var events2 = Mock.Of <Events2>();

            var dte2 = Mock.Of <DTE2>(d => d.Events == events2);

            kernel.Bind <DTE2>().ToConstant(dte2);

            kernel.Bind <ICommand>().ToMethod(context => Mock.Of <OpenOptionsPage>());

            kernel.Bind <ViewModelService>().ToMethod(context =>
            {
                serviceResolved = true;
                return(new ViewModelService());
            });

            // Act

            package.InitializeServices(
                kernel,
                Mock.Of <IOptionsPageService>());

            // Assert

            Assert.IsTrue(serviceResolved);
        }
        public void InitializeServicesSubscribesToDte2Events()
        {
            // Arrange

            var package = new WorkingFilesWindowPackage();
            var kernel  = new MoqMockingKernel();

            var events2 = Mock.Of <Events2>();
            var dte2    = Mock.Of <DTE2>(d => d.Events == events2);

            kernel.Bind <DTE2>().ToConstant(dte2);
            kernel.Bind <ICommand>().ToMethod(context => Mock.Of <OpenOptionsPage>());

            var subscriberMock = new Mock <IDteEventsSubscriber>();

            kernel.Bind <IDteEventsSubscriber>().ToConstant(subscriberMock.Object);

            // Act

            package.InitializeServices(
                kernel,
                Mock.Of <IOptionsPageService>());

            // Assert

            subscriberMock.Verify(s => s.SubscribeTo(events2));
        }
        public void InitializeServicesSynchronizesDocuments()
        {
            // Arrange

            var package = new WorkingFilesWindowPackage();
            var kernel  = new MoqMockingKernel();

            var documents = Mock.Of <Documents>();

            var dte2 = Mock.Of <DTE2>(d =>
                                      d.Events == Mock.Of <Events2>() &&
                                      d.Documents == documents);

            kernel.Bind <DTE2>().ToConstant(dte2);
            kernel.Bind <ICommand>().ToMethod(context => Mock.Of <OpenOptionsPage>());

            var subscriberMock = new Mock <IDteEventsSubscriber>();

            kernel.Bind <IDteEventsSubscriber>().ToConstant(subscriberMock.Object);

            var managerMock = new Mock <IDocumentMetadataManager>();

            kernel.Bind <IDocumentMetadataManager>().ToConstant(managerMock.Object);

            // Act

            package.InitializeServices(
                kernel,
                Mock.Of <IOptionsPageService>());

            // Assert

            managerMock.Verify(m => m.Synchronize(documents, true));
        }
        public void ShowOptionsPageIsInvokedOnExecutingOpenOptionsPageAfterInitializingServices()
        {
            // Arrange

            var openOptionsPage    = new OpenOptionsPage();
            var optionsPageService = Mock.Of <IOptionsPageService>();

            var kernel = new MoqMockingKernel();

            kernel.Bind <ICommand>().ToConstant(openOptionsPage);

            var package = new WorkingFilesWindowPackage();

            package.InitializeServices(kernel, optionsPageService);

            // Act

            openOptionsPage.Execute(null);

            // Assert

            Mock.Get(optionsPageService).Verify(o => o.ShowOptionPage(
                                                    typeof(OptionsPage)));
        }