Пример #1
0
 public void AlbumFactoryConstructMissingArtTest()
 {
     var target = new AlbumFactory();
     var raw = XElement.Parse(@"
     <album id=""2910"">
     <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>
     <preciserating>3</preciserating>
     <rating>2.9</rating>
     </album>");
     var actual = target.Construct(raw);
     Assert.That(actual, Is.Not.Null);
     Assert.That(actual.Id, Is.EqualTo(2910));
     Assert.That(actual.ArtId, Is.EqualTo(2910));
     Assert.That(actual.ArtistId, Is.EqualTo(129348));
     Assert.That(actual.ArtistName, Is.EqualTo("AC/DC"));
     Assert.That(actual.Name, Is.EqualTo("Back in Black"));
     Assert.That(actual.PerciseRating, Is.EqualTo(3));
     Assert.That(actual.Rating, Is.EqualTo(3));
     Assert.That(actual.Tags.Count, Is.EqualTo(3)); // NOTE: test the tag factory in a different fixture
     Assert.That(actual.TrackCount, Is.EqualTo(12));
     Assert.That(actual.Year, Is.EqualTo(1984));
     Assert.That(actual.ArtUrl, Is.Null);
 }
Пример #2
0
 public void AlbumFactoryConstructMissingArtistTest()
 {
     var target = new AlbumFactory();
     var raw = XElement.Parse(@"
     <album id=""2910"">
     <name>Back in Black</name>
     <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>
     </album>");
     var actual = target.Construct(raw);
     Assert.That(actual, Is.Not.Null);
     Assert.That(actual.Id, Is.EqualTo(2910));
     Assert.That(actual.ArtId, Is.EqualTo(2910));
     Assert.That(actual.ArtistId, Is.EqualTo(0));
     Assert.That(actual.ArtistName, Is.EqualTo(string.Empty));
     Assert.That(actual.Name, Is.EqualTo("Back in Black"));
     Assert.That(actual.PerciseRating, Is.EqualTo(3));
     Assert.That(actual.Rating, Is.EqualTo(3)); // NOTE: not sure that is correct, but it will work
     Assert.That(actual.Tags.Count, Is.EqualTo(3)); // NOTE: test the tag factory in a different fixture
     Assert.That(actual.TrackCount, Is.EqualTo(12));
     Assert.That(actual.Year, Is.EqualTo(1984));
     Assert.That(actual.ArtUrl, Is.EqualTo("http://localhost/image.php?id=129348"));
 }
Пример #3
0
        public AlbumService(IHostingEnvironment env)
        {
            _enviroment = env;
            AlbumFactory _albumFactory = AlbumFactory.Instance;

            albums.Add(_albumFactory.CreateAlbum("Landscape"));
            albums.Add(_albumFactory.CreateAlbum("People"));
            albums.Add(_albumFactory.CreateAlbum("Tech"));
        }
Пример #4
0
        /// <summary>
        /// Arrange the Design instance of the Music Collection
        /// for use as the unit test context.
        /// </summary>
        /// <returns>An instance of the Design time Music Collection</returns>
        internal static MusicCollection Arrange_Db()
        {
            //  Instantiate the factories for creating the objects
            var _artistFactory = new ArtistFactory();
            var _wikiFactory = new WikiFactory();
            var _albumFactory = new AlbumFactory(_artistFactory, _wikiFactory);
            var _trackFactory = new TrackFactory(_artistFactory, _albumFactory);
            var _imageFactory = new ImageFactory();

            //  Instantiate the DesignMusicCollection which contains static data, used at design time, 
            //return new DesignMusicCollection(_artistFactory, _albumFactory, _trackFactory, _imageFactory);

            return null;
        }
Пример #5
0
 public FileSystemAlbumProvider(
     IFileSystem fileSystem,
     AlbumFactory<FileSystemAlbum> albumFactory,
     AlbumItemFactory itemFactory,
     IAuthorizationService authorization,
     ObjectCache cache
     )
 {
     this.fileSystem = fileSystem;
     this.albumFactory = albumFactory;
     this.itemFactory = itemFactory;
     this.authorization = authorization;
     this.cache = cache;
 }
Пример #6
0
 public PersonAlbumProvider(
     AlbumFactory<PersonAlbum> albumFactory,
     AlbumItemFactory itemFactory,
     FileSystemAlbumProvider primaryAlbumProvider,
     IFaceProvider[] faceProviders,
     IAuthorizationService authorization,
     ObjectCache faceCache
     )
 {
     this.albumFactory = albumFactory;
     this.itemFactory = itemFactory;
     this.primaryAlbumProvider = primaryAlbumProvider;
     this.faceProviders = faceProviders;
     this.authorization = authorization;
     this.faceCache = faceCache;
 }
Пример #7
0
 public void AlbumFactoryConstructBadXmlTest()
 {
     var target = new AlbumFactory();
     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();
 }