コード例 #1
0
ファイル: Bootstrapper.cs プロジェクト: won21kr/Warewolf
        /*
         * DELETE THIS METHOD AND LOOSE A VERY IMPORTANT PART OF YOU ;)
         *
         * IT IS REQUIRED FOR UPDATES IN RELEASE MODE ;)
         * REMOVING IT MEANS IT IS NOT POSSIBLE TO BUILD AN INSTALLER ;)
         */
        // ReSharper disable once UnusedMember.Local
        private bool CheckWindowsService()
        {
            IWindowsServiceManager     windowsServiceManager = CustomContainer.Get <IWindowsServiceManager>();
            IPopupController           popup = CustomContainer.Get <IPopupController>();
            ServerServiceConfiguration ssc   = new ServerServiceConfiguration(windowsServiceManager, popup);

            if (ssc.DoesServiceExist())
            {
                if (ssc.IsServiceRunning())
                {
                    return(true);
                }

                if (ssc.PromptUserToStartService())
                {
                    if (ssc.StartService())
                    {
                        _serverServiceStartedFromStudio = true;
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #2
0
#pragma warning disable CC0091 // Use static method
#pragma warning disable CC0038 // You should use expression bodied members whenever possible.
        bool CheckWindowsService()
#pragma warning restore CC0091 // Use static method
        {
#if DEBUG
            return(true);
#else
            IWindowsServiceManager     windowsServiceManager = CustomContainer.Get <IWindowsServiceManager>();
            IPopupController           popup = CustomContainer.Get <IPopupController>();
            ServerServiceConfiguration ssc   = new ServerServiceConfiguration(windowsServiceManager, popup);

            if (ssc.DoesServiceExist())
            {
                if (ssc.IsServiceRunning())
                {
                    return(true);
                }

                if (ssc.PromptUserToStartService())
                {
                    if (ssc.StartService())
                    {
                        _serverServiceStartedFromStudio = true;
                        return(true);
                    }
                }
            }

            return(false);
#endif
        }
コード例 #3
0
        public void ServerServiceConfiguration_PromptUserToStartService_WhenNullServiceConfiguration_ExpectException()
        {
            //------------Setup for test--------------------------
            var serverServiceConfiguration = new ServerServiceConfiguration(null);

            //------------Execute Test---------------------------
            serverServiceConfiguration.PromptUserToStartService();
        }
コード例 #4
0
        static ServerServiceConfiguration CreateServerServiceConfiguration(bool isServiceRunning)
        {
            Mock <IWindowsServiceManager> serviceManager = new Mock <IWindowsServiceManager>();

            serviceManager.Setup(sm => sm.IsRunning()).Returns(isServiceRunning);

            var serverServiceConfiguration = new ServerServiceConfiguration(serviceManager.Object);

            return(serverServiceConfiguration);
        }
コード例 #5
0
        static ServerServiceConfiguration CreateServerServiceConfiguration(bool isServiceRunning, bool startServiceResult)
        {
            Mock <IWindowsServiceManager> serviceManager = new Mock <IWindowsServiceManager>();

            serviceManager.Setup(sm => sm.IsRunning()).Returns(isServiceRunning);
            serviceManager.Setup(sm => sm.Start()).Returns(startServiceResult);
            serviceManager.Setup(sm => sm.Exists()).Returns(true);

            var serverServiceConfiguration = new ServerServiceConfiguration(serviceManager.Object);

            return(serverServiceConfiguration);
        }
コード例 #6
0
        static ServerServiceConfiguration CreateServerServiceConfiguration(bool isServiceRunning, MessageBoxResult promptResult, out Mock <IPopupController> ctrl)
        {
            Mock <IWindowsServiceManager> serviceManager = new Mock <IWindowsServiceManager>();

            serviceManager.Setup(sm => sm.IsRunning()).Returns(isServiceRunning);

            Mock <IPopupController> controller = new Mock <IPopupController>();

            controller.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>())).Verifiable();
            controller.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>())).Returns(promptResult);

            ctrl = controller;

            var serverServiceConfiguration = new ServerServiceConfiguration(serviceManager.Object, controller.Object);

            return(serverServiceConfiguration);
        }
コード例 #7
0
        static ServerServiceConfiguration CreateServerServiceConfiguration(bool isServiceRunning, bool startServiceResult, bool serviceExist, out Mock <IPopupController> ctrl)
        {
            var serviceManager = new Mock <IWindowsServiceManager>();

            serviceManager.Setup(sm => sm.IsRunning()).Returns(isServiceRunning);
            serviceManager.Setup(sm => sm.Start()).Returns(startServiceResult);
            serviceManager.Setup(sm => sm.Exists()).Returns(serviceExist);

            var controller = new Mock <IPopupController>();

            controller.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>())).Verifiable();

            // set for out arg
            ctrl = controller;

            var serverServiceConfiguration = new ServerServiceConfiguration(serviceManager.Object, controller.Object);

            return(serverServiceConfiguration);
        }