public void SettingResolution_WhenCall_CheckResolutionNotSupported(int width, int height)
        {
            //Arrange
            ScreenResolutionService screenResolutionAdapter = Substitute.For <ScreenResolutionService>();
            Resolution resolutionMock = new Resolution()
            {
                width = width, height = height
            };

            screenResolutionAdapter.ResolutionsSupported.Returns(new Resolution[] { resolutionMock });
            Container.Bind <ScreenResolutionService>().FromInstance(screenResolutionAdapter);

            ScreenResolutionAutoDetectService resolutionSetter = Container.Resolve <ScreenResolutionAutoDetectService>();

            //Assert
            Assert.Throws <Exception>(() => resolutionSetter.SettingResolution());
        }
        public void SettingResolution_WhenCall_CheckScreenHDResolution()
        {
            //Arrange
            Resolution resolutionHDMock = new Resolution()
            {
                width = 1280, height = 720
            };
            ScreenResolutionService screenResolutionAdapter = Substitute.For <ScreenResolutionService>();

            screenResolutionAdapter.ResolutionsSupported.Returns(new Resolution[] { resolutionHDMock });
            Container.Bind <ScreenResolutionService>().FromInstance(screenResolutionAdapter);

            ScreenResolutionAutoDetectService resolutionSetter = Container.Resolve <ScreenResolutionAutoDetectService>();

            //Act
            resolutionSetter.SettingResolution();

            //Assert
            screenResolutionAdapter.Received().SetResolution(1280, 720, true, 60);
        }
示例#3
0
        instantiateWDCServices()
        {
            // Create typed loggers.
            // See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1#non-host-console-app
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("System", LogLevel.Warning)
                .AddFilter("Default", LogLevel.Information)
                .AddConsole();
            });

            var screenResolutionServiceLogger = loggerFactory.CreateLogger <ScreenResolutionService>();
            var streamSourceServiceLogger     = loggerFactory.CreateLogger <StreamSourceService>();
            var restApiClientServiceLogger    = loggerFactory.CreateLogger <RestApiClientService>();
            var mainWindowViewModelLogger     = loggerFactory.CreateLogger <MainWindowViewModel>();

            // Find out the operating-System and according to it, specify
            // the concrete type for the needed IServiceProvider
            // Either "Linux", "Windows", or "macOS"
            string operatingSystem;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                operatingSystem = "Linux";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                operatingSystem = "macOS";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                operatingSystem = "Windows";
            }
            else
            {
                throw new Exception("Operating System not supported");
            }

            // Extract necessary strings from configuration (App.config)
            NameValueCollection config = ConfigurationManager.AppSettings;

            string shell             = config[$"shell_{operatingSystem}"];
            string shellArgsTemplate = config[$"shell_Args_Template_{operatingSystem}"];
            string startStreamingSourceScriptPath            = config[$"Start_Streaming_Source_Script_Path_{operatingSystem}"];
            string startStreamingSourceScriptArgsTemplate    = config[$"Start_Streaming_Source_Script_Args_Template_{operatingSystem}"];
            string manageScreenResolutionsScriptPath         = config[$"Manage_Screen_Resolutions_Script_Path_{operatingSystem}"];
            string manageScreenResolutionsScriptArgsTemplate = config[$"Manage_Screen_Resolutions_Script_Args_Template_{operatingSystem}"];
            int    preferredScreenWidth = Convert.ToInt32(config[$"Preferred_Screen_Width_{operatingSystem}"]);

            IScreenResolutionService screenResolutionService = new ScreenResolutionService(
                logger: screenResolutionServiceLogger,
                shell: shell,
                shellArgsTemplate: shellArgsTemplate,
                manageScreenResolutionsScriptPath: manageScreenResolutionsScriptPath,
                manageScreenResolutionsScriptArgsTemplate: manageScreenResolutionsScriptArgsTemplate
                );

            IStreamSourceService streamSourceService = new StreamSourceService(
                logger: streamSourceServiceLogger,
                shell: shell,
                shellArgsTemplate: shellArgsTemplate,
                startStreamingSourceScriptPath: startStreamingSourceScriptPath,
                startStreamingSourceScriptArgsTemplate: startStreamingSourceScriptArgsTemplate
                );

            IRestApiClientService restApiClientService = new RestApiClientService(
                logger: restApiClientServiceLogger
                );

            return(Tuple.Create(mainWindowViewModelLogger,
                                screenResolutionService,
                                streamSourceService,
                                restApiClientService,
                                preferredScreenWidth));
        }