예제 #1
0
        public void FilmFactory_builds_a_film_from_path_and_filesystem()
        {
            var   fileSystem = new MockFileSystem();
            IFilm film       = FilmFactory <FilmFromFolder> .BuildFilm(@"C:\Media\A", fileSystem);

            Assert.AreEqual(typeof(FilmFromFolder), film.GetType());
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        public ListFilmViewModel()
        {
            ListFilm  = FilmFactory.AllFilmEntitieToFilm(FilmDAO.GetAllFilm());
            ToDisplay = ListFilm;

            AddCommand    = new DelegateCommand(OnAddCommand, CanAddCommand);
            EditCommand   = new DelegateCommand(OnEditCommand, CanEditCommand);
            SupprCommand  = new DelegateCommand(OnSupprCommand, CanSupprCommand);
            SearchCommand = new DelegateCommand(OnSearchCommand, CanSearchCommand);
            SaveCommand   = new DelegateCommand(OnSaveCommand, CanSaveCommand);
        }
예제 #3
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Too few input parameters");
                return;
            }

            string[] lines;
            string   inFilePath  = args[0];
            string   outFilePath = args[1];
            string   logFilePath = args.Length > 2 ? args[2] : "log.txt";

            try
            {
                lines = File.ReadAllLines(inFilePath);
            }
            catch (Exception e)
            {
                File.AppendAllText(logFilePath, $"{DateTime.Now}: {e.Message}{Environment.NewLine}");
                return;
            }

            MyList films = new MyList();
            int    i     = 0;

            foreach (string data in lines)
            {
                try
                {
                    films.Add(FilmFactory.CreateFilm(++i, data));
                }
                catch (Exception e)
                {
                    File.AppendAllText(logFilePath, $"{DateTime.Now}: {e.Message}{Environment.NewLine}");
                }
            }

            Predicate <Film> ratingLessThanSeven = (Film film) => { return(film.Rating < 7.0f); };

            films.Remove(ratingLessThanSeven);
            films.Sort();

            i = 0;
            File.WriteAllText(outFilePath, "");

            foreach (Film film in films)
            {
                File.AppendAllText(outFilePath, $"{++i} - {film}{Environment.NewLine}");
            }

            File.AppendAllText(outFilePath, $"Count of elements: {films.Count}{Environment.NewLine}");
        }
예제 #4
0
 public void It_should_build_a_mock_film_from_a_path()
 {
     Assert.AreEqual(typeof(FilmMock), FilmFactory <FilmMock> .BuildFilm(@"C:\Media\A").GetType());
 }
예제 #5
0
 protected virtual void OnChangeAction(string path, IFilmProcessor filmProcessor)
 {
     filmProcessor.Process(FilmFactory <T> .BuildFilm(path));
 }