Exemplo n.º 1
0
 public void PlaylistFactoryConstructMissingArtistTest()
 {
     var target = new SongFactory();
     var raw = XElement.Parse(@"
     <song id=""3180"">
     <title>Hells Bells</title>
     <album id=""2910"">Back in Black</album>
     <tag id=""2481"" count=""3"">Rock &amp; Roll</tag>
     <tag id=""2482"" count=""1"">Rock</tag>
     <tag id=""2483"" count=""1"">Roll</tag>
     <track>4</track>
     <time>234</time>
     <url>http://localhost/play/index.php?oid=123908...</url>
     <size>Song Filesize in Bytes</size>
     <art>http://localhost/image.php?id=129348</art>
     <preciserating>3</preciserating>
     <rating>2.9</rating>
     </song>");
     var actual = target.Construct(raw);
     Assert.That(actual.Name, Is.EqualTo("Hells Bells"));
     Assert.That(actual.AlbumId, Is.EqualTo(2910));
     Assert.That(actual.AlbumName, Is.EqualTo("Back in Black"));
     Assert.That(actual.ArtistId, Is.EqualTo(0));
     Assert.That(actual.ArtistName, Is.Null);
     Assert.That(actual.ArtId, Is.EqualTo(2910));
     Assert.That(actual.ArtUrl, Is.EqualTo("http://localhost/image.php?id=129348"));
     Assert.That(actual.PerciseRating, Is.EqualTo(3));
     Assert.That(actual.Rating, Is.EqualTo(3));
     Assert.That(actual.Tags.Count, Is.EqualTo(3));
     Assert.That(actual.TrackLength, Is.EqualTo(TimeSpan.FromSeconds(234)));
     Assert.That(actual.TrackNumber, Is.EqualTo(4));
     Assert.That(actual.Url, Is.EqualTo("http://localhost/play/index.php?oid=123908..."));
 }
        public IFileObjectFactory GetFileObject(string ObjectType)
        {
            IFileObjectFactory fileobject;

            switch (ObjectType)
            {
            case "Band":
                fileobject = new BandFactory(repository);
                break;

            case "Song":
                fileobject = new SongFactory(repository);
                break;

            case "MusicGenre":
                fileobject = new MusicGenreFactory(repository);
                break;

            case "BandsRecord":
                fileobject = new BandsRecordFactory(repository);
                break;

            default:
                fileobject = null;
                break;
            }

            return(fileobject);
        }
 public FestivalController(IStage stage)
 {
     this.stage             = stage;
     this.setFactory        = new SetFactory();
     this.instrumentFactory = new InstrumentFactory();
     this.performerFactory  = new PerformerFactory();
     this.songFactory       = new SongFactory();
 }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            IReader             reader             = new ConsoleReader();
            IWriter             writer             = new ConsoleWriter();
            IStage              stage              = new Stage();
            IInstrumentFactory  instrumentFactory  = new InstrumentFactory();
            IPerformerFactory   performerFactory   = new PerformerFactory();
            ISongFactory        songFactory        = new SongFactory();
            IFestivalController festivalController = new FestivalController(stage, instrumentFactory, performerFactory, songFactory);
            ISetController      setController      = new SetController(stage);

            var engine = new Engine(reader, writer, stage, festivalController, setController);

            engine.Run();
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            IList <ISet>       sets       = new List <ISet>();
            IList <ISong>      songs      = new List <ISong>();
            IList <IPerformer> performers = new List <IPerformer>();

            Stage stage = new Stage(sets, songs, performers);

            IReader            reader            = new ConsoleReader();
            IWriter            writer            = new ConsoleWriter();
            ISetFactory        setFactory        = new SetFactory();
            IInstrumentFactory instrumentFactory = new InstrumentFactory();
            IPerformerFactory  performerFactory  = new PerformerFactory();
            ISongFactory       songFactory       = new SongFactory();

            IFestivalController festivalController = new FestivalController(stage, setFactory, instrumentFactory, performerFactory, songFactory);
            ISetController      setController      = new SetController(stage);

            var engine = new Engine(reader, writer, festivalController, setController);

            engine.Run();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            try
            {
                if (IsValidPaths(args) == false)
                {
                    throw new Exception("Invalid paths");
                }

                var songsDescriptionPath = args[0];
                var mp3FilePath          = args[1];

                var factory = new SongFactory(new FileSystem());
                factory.ReadFileAndGenerateSongs($@"{songsDescriptionPath}", $@"{mp3FilePath}");

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
Exemplo n.º 7
0
        public JsonResult AddFile()
        {
            var files = new List<string>();
            foreach (string file in Request.Files)
            {
                var hpf = Request.Files[file];
                if (hpf.ContentLength == 0)
                    continue;

                var path =
                    Path.Combine(Server.MapPath("~/Content/Music/"),
                        hpf.FileName);
                files.Add(path);

                hpf.SaveAs(Path.GetFullPath(path));
            }
            if (!files.Any()) return Json("No Files");

            var factory = new SongFactory(_mediaFileRepository);

            var songs = factory.MultiCreateSong(files);
            return Json(songs.Select(x => x.Name).First() + " uploaded");
        }
Exemplo n.º 8
0
 public void SongFactoryConstructBadXmlTest()
 {
     var target = new SongFactory();
     var raw = XElement.Parse(@"
     <albums>
     <name>Back in Black</name>
     <artist id=""129348"">AC/DC</artist>
     <year>1984</year>
     <tracks>12</tracks>
     <disk>1</disk>
     <tag id=""2482"" count=""1"">Rock &amp; Roll</tag>
     <tag id=""2482"" count=""1"">Rock</tag>
     <tag id=""2483"" count=""1"">Roll</tag>
     <art>http://localhost/image.php?id=129348</art>
     <preciserating>3</preciserating>
     <rating>2.9</rating>
     </albums>");
     var actual = target.Construct(raw);
     Assert.Fail();
 }
Exemplo n.º 9
0
 public void PlaylistFactoryConstructMissingUrlTest()
 {
     var target = new SongFactory();
     var raw = XElement.Parse(@"
     <song id=""3180"">
     <title>Hells Bells</title>
     <artist id=""129348"">AC/DC</artist>
     <album id=""2910"">Back in Black</album>
     <tag id=""2481"" count=""3"">Rock &amp; Roll</tag>
     <tag id=""2482"" count=""1"">Rock</tag>
     <tag id=""2483"" count=""1"">Roll</tag>
     <track>4</track>
     <time>234</time>
     <size>Song Filesize in Bytes</size>
     <art>http://localhost/image.php?id=129348</art>
     <preciserating>3</preciserating>
     <rating>2.9</rating>
     </song>");
     var actual = target.Construct(raw);
     Assert.Fail();
 }