public async Task TestWriteMessageToDriverSucceeds()
        {
            // Arrange
            var testConfigProvider = new TestConfigProvider();
            var testConfig         = new TextDisplayConfig()
            {
                DriverType     = "MockDisplayDriver.MockDisplayDriver",
                DriverAssembly = "MockDisplayDriver",
                Height         = 0,
                Width          = 0
            };

            (testConfigProvider.Configs as List <TextDisplayConfig>).Add(testConfig);

            var testMessage = "testMessage";

            List <ITextDisplay> returnedDisplays;

            // Act
            returnedDisplays = await TextDisplayManager.GetDisplaysForProvider(testConfigProvider) as List <ITextDisplay>;

            await returnedDisplays[0].WriteMessageAsync(testMessage, 0);

            // Assert
            Assert.AreEqual(1, returnedDisplays.Count, "1 display should be returned");
            var mockDriver = returnedDisplays[0] as MockDisplayDriver.MockDisplayDriver;

            Assert.IsNotNull(mockDriver, "Manager did not return mock driver");
            Assert.AreEqual(testMessage, mockDriver.LastMessage);
        }
        public async Task TestDriverConfigValuesPassedToDriverSucceeds()
        {
            // Arrange
            var testConfigProvider    = new TestConfigProvider();
            var testDriverConfigName  = "testDriverConfigName";
            var testDriverConfigValue = "testDriverConfigValue";

            var testConfig = new TextDisplayConfig()
            {
                DriverType     = "MockDisplayDriver.MockDisplayDriver",
                DriverAssembly = "MockDisplayDriver",
                Height         = 0,
                Width          = 0
            };

            testConfig.DriverConfigurationValues.Add(testDriverConfigName, testDriverConfigValue);
            (testConfigProvider.Configs as List <TextDisplayConfig>).Add(testConfig);

            List <ITextDisplay> returnedDisplays;

            // Act
            returnedDisplays = await TextDisplayManager.GetDisplaysForProvider(testConfigProvider) as List <ITextDisplay>;

            // Assert
            Assert.AreEqual(1, returnedDisplays.Count, "1 display should be returned");
            var mockDriver = returnedDisplays[0] as MockDisplayDriver.MockDisplayDriver;

            Assert.IsNotNull(mockDriver);
            Assert.AreEqual(mockDriver.Config.DriverConfigurationValues[testDriverConfigName], testDriverConfigValue);
        }
    public void setActiveUIComponent(You.NAME activeCharacter)
    {
        if (activeCharacter == You.NAME.GRAHAM)
        {
            this.activeTextDisplayManager = GrahamTextDisplay;

            this.activeChoiceButtonManager = GrahamChoiceButtons;

            this.activeDialogueAnimationController = GrahamDialogueBoxAnimationController;

            this.ShioTextDisplay.gameObject.SetActive(false);
            this.ShioChoiceButtons.gameObject.SetActive(false);
        }
        else
        {
            this.activeTextDisplayManager = ShioTextDisplay;

            this.activeChoiceButtonManager = ShioChoiceButtons;

            this.activeDialogueAnimationController = ShioDialogueBoxAnimationController;

            this.GrahamTextDisplay.gameObject.SetActive(false);
            this.GrahamChoiceButtons.gameObject.SetActive(false);
        }

        this.activeTextDisplayManager.gameObject.SetActive(true);
        this.activeChoiceButtonManager.gameObject.SetActive(true);

        resetUIInitialState();
    }
        public async Task TestNoConfigsReturnsEmptyListSucceeds()
        {
            // Arrange
            var testConfigProvider = new TestConfigProvider();
            List <ITextDisplay> returnedDisplays;

            // Act
            returnedDisplays = await TextDisplayManager.GetDisplaysForProvider(testConfigProvider) as List <ITextDisplay>;

            // Assert
            Assert.AreEqual(0, returnedDisplays.Count, "No displays should be returned");
        }
        public async Task TestNonExistentBuiltInDriverTypeFails()
        {
            // Arrange
            var testConfigProvider = new TestConfigProvider();
            var testConfig         = new TextDisplayConfig()
            {
                DriverType = "NonExistentDriver",
                Height     = 0,
                Width      = 0
            };

            (testConfigProvider.Configs as List <TextDisplayConfig>).Add(testConfig);
            List <ITextDisplay> returnedDisplays;

            // Act
            returnedDisplays = await TextDisplayManager.GetDisplaysForProvider(testConfigProvider) as List <ITextDisplay>;

            // Assert
            Assert.AreEqual(0, returnedDisplays.Count, "No displays should be returned");
        }
        public async Task TestOneConfigReturnsOneDisplaySucceeds()
        {
            // Arrange
            var testConfigProvider = new TestConfigProvider();
            var testConfig         = new TextDisplayConfig()
            {
                DriverType     = "MockDisplayDriver.MockDisplayDriver",
                DriverAssembly = "MockDisplayDriver",
                Height         = 0,
                Width          = 0
            };

            (testConfigProvider.Configs as List <TextDisplayConfig>).Add(testConfig);
            List <ITextDisplay> returnedDisplays;

            // Act
            returnedDisplays = await TextDisplayManager.GetDisplaysForProvider(testConfigProvider) as List <ITextDisplay>;

            // Assert
            Assert.AreEqual(1, returnedDisplays.Count, "1 display should be returned");
        }
Esempio n. 7
0
 private void Awake()
 {
     _instance   = this;
     displayText = GetComponent <Text> ();
 }
Esempio n. 8
0
        public IAsyncAction Initialize(InternetRadioConfig config)
        {
            return(Task.Run(async() =>
            {
                this.config = config;
                this.playbackRetries = 0;

                var telemetryInitializeProperties = new Dictionary <string, string>();
#pragma warning disable CS0618 // No current view for Background task
                this.resourceLoader = new ResourceLoader("Resources");
#pragma warning restore CS0618 // No current view for Background task

                this.radioPowerManager = new RadioPowerManager();
                this.radioPowerManager.PowerStateChanged += RadioPowerManager_PowerStateChanged;

                this.radioPresetManager = new RadioLocalPresetManager();
                this.radioPresetManager.PlaylistChanged += RadioPresetManager_PlaylistChanged;
                this.radioPresetManager.CurrentTrackChanged += RadioPresetManager_CurrentTrackChanged;

                this.radioPlaybackManager = new MediaEnginePlaybackManager();
                this.radioPlaybackManager.VolumeChanged += RadioPlaybackManager_VolumeChanged;
                this.radioPlaybackManager.PlaybackStateChanged += RadioPlaybackManager_PlaybackStateChanged;
                await this.radioPlaybackManager.InitialzeAsync();

                // Initialize the input managers

                // AllJoyn
                this.allJoynInterfaceManager = new AllJoynInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                this.allJoynInterfaceManager.Initialize();

                // GPIO
                this.gpioInterfaceManager = new GpioInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                if (!this.gpioInterfaceManager.Initialize(this.config.Buttons_Debounce, this.config.Buttons_Pins))
                {
                    Debug.WriteLine("RadioManager: Failed to initialize GPIO");
                    telemetryInitializeProperties.Add("GpioAvailable", false.ToString());
                }
                else
                {
                    telemetryInitializeProperties.Add("GpioAvailable", true.ToString());
                }

                // HTTP
                this.httpInterfaceManager = new HttpInterfaceManager(8001, this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                this.httpInterfaceManager.StartServer();

                // Manage settings
                this.radioPlaybackManager.Volume = this.loadVolume();
                var previousPlaylist = this.loadPlaylistId();
                if (previousPlaylist.HasValue)
                {
                    await this.radioPresetManager.LoadPlayList(previousPlaylist.Value);
                    telemetryInitializeProperties.Add("FirstBoot", false.ToString());
                }
                else
                {
                    telemetryInitializeProperties.Add("FirstBoot", true.ToString());
                    this.radioPlaybackManager.Volume = .25;
                }

                if (this.radioPresetManager.CurrentPlaylist == null)
                {
                    var newPlaylistId = await this.radioPresetManager.StartNewPlaylist("DefaultPlaylist", new List <Track>(), true);
                    this.savePlaylistId(newPlaylistId);
                }

                var displays = await TextDisplayManager.GetDisplays();
                this.display = displays.FirstOrDefault();
                if (null != this.display)
                {
                    telemetryInitializeProperties.Add("DisplayAvailable", true.ToString());
                    telemetryInitializeProperties.Add("DisplayHeight", this.display.Height.ToString());
                    telemetryInitializeProperties.Add("DisplayWidth", this.display.Width.ToString());
                }
                else
                {
                    Debug.WriteLine("RadioManager: No displays available");
                    telemetryInitializeProperties.Add("DisplayAvailable", false.ToString());
                }

                // Wake up the radio
                this.radioPowerManager.PowerState = PowerState.Powered;

                if (this.radioPresetManager.CurrentPlaylist.Tracks.Count <= 0)
                {
                    this.radioPresetManager.CurrentPlaylist.Tracks.Add(this.config.Playlist_BuiltInStation);
                }

                TelemetryManager.WriteTelemetryEvent("App_Initialize", telemetryInitializeProperties);
            }).AsAsyncAction());
        }