Ejemplo n.º 1
0
        public void PlaylistsPanelLoad_ShouldCreateOneAssociationControlPerAvailablePlaylist()
        {
            List <Playlist> playlists = BuildListOfDummyPlaylists(2);
            ModelRepository model     = new ModelRepository();

            model.Add("devices", new DeviceCollection());

            MockMediaSoftwareService mockMediaSoftwareService = new MockMediaSoftwareService();

            mockMediaSoftwareService.SetPlaylists(playlists);

            PlaylistsPanel playlistsPanel = new PlaylistsPanel();

            playlistsPanel.MediaSoftwareService = mockMediaSoftwareService;
            playlistsPanel.Model = model;

            playlistsPanel.PlaylistsPanel_Load(this, null);

            int numberOfAssociationControlsCreated = 0;

            foreach (Control panelControl in playlistsPanel.FlowPlaylistAssociations.Controls)
            {
                Console.WriteLine(String.Format("Control type: {0}", panelControl.GetType().ToString()));
                if (panelControl is PlaylistAssociationControl)
                {
                    numberOfAssociationControlsCreated++;
                }
            }

            Assert.AreEqual(playlists.Count(), numberOfAssociationControlsCreated);
        }
Ejemplo n.º 2
0
        private static void LoadStoredDevices(ModelRepository repo)
        {
            // If there are no current stored devices config, simply add a new DeviceCollection.
            if (!File.Exists(DEVICES_CONFIG_PATH))
            {
                repo["devices"] = new DeviceCollection();
                return;
            }

            Stream read;

            try
            {
                read = new FileStream(DEVICES_CONFIG_PATH, FileMode.Open);
            }
            catch (Exception ex)
            {
                throw new IOException("Unable to load stored devices configuration.", ex);
            }

            try
            {
                repo.Deserialize("devices", typeof(iTunesAgent.Domain.DeviceCollection), read);
            }
            finally
            {
                if (read != null)
                {
                    read.Close();
                }
            }
        }
Ejemplo n.º 3
0
        /*!
         * Populates the ModelRepository with configuration from file.
         */
        public static ModelRepository LoadModelRepository(ConfigurationChecker configurationChecker)
        {
            ModelRepository repo = new ModelRepository();

            LoadApplicationConfiguration(configurationChecker, repo);
            LoadStoredDevices(repo);
            LoadStoredPatterns(repo);

            return(repo);
        }
Ejemplo n.º 4
0
        private static void LoadApplicationConfiguration(ConfigurationChecker configurationChecker, ModelRepository repo)
        {
            Stream read;

            try
            {
                configurationChecker.CheckConfiguration();
                read = new FileStream(APP_CONFIG_PATH, FileMode.Open);
            }
            catch (Exception ex)
            {
                throw new IOException("Unable to load application configuration.", ex);
            }

            try
            {
                repo.Deserialize("appconfig", typeof(iTunesAgent.Domain.Configuration), read);
            }
            finally
            {
                if (read != null)
                {
                    read.Close();
                }
            }
        }
Ejemplo n.º 5
0
 private void LoadConfiguration()
 {
     modelRepository = ApplicationUtils.LoadModelRepository(configurationChecker);
 }