public new void SetUp()
    {
        base.SetUp();

        service = new DatabaseCatalogService();
        dto     = service.FindByRecordingId(Recording.Id);
    }
        public void SetUp()
        {
            base.SetUp();

            service = new DatabaseCatalogService();
            dto = service.FindByRecordingId(Recording.Id);
        }
Exemple #3
0
        public void AverageRatingZero()
        {
            RecordingDataSet dataSet = new RecordingDataSet();

            RecordingDataSet.Recording recording =
                dataSet.Recordings.NewRecording();
            recording.Id          = 1;
            recording.Title       = "Title";
            recording.ReleaseDate = DateTime.Today;

            RecordingDataSet.Label label = dataSet.Labels.NewLabel();
            label.Id   = 1;
            label.Name = "Label";
            dataSet.Labels.AddLabel(label);

            RecordingDataSet.Artist artist = dataSet.Artists.NewArtist();
            artist.Id   = 1;
            artist.Name = "Artist";
            dataSet.Artists.AddArtist(artist);

            recording.Label  = label;
            recording.Artist = artist;
            dataSet.Recordings.AddRecording(recording);

            RecordingDto dto = RecordingAssembler.WriteDto(recording);

            Assert.AreEqual(0, dto.averageRating);
        }
        public void SetUp()
        {
            // create a test recording in memory
            recording = InMemoryRecordingBuilder.Make();

            service = new StubCatalogService(recording);
            dto = service.FindByRecordingId(recording.Id);
        }
        public RecordingViewModel(RecordingDto recording)
        {
            Id             = recording.Id;
            Title          = recording.Title;
            Length         = recording.Length;
            Disambiguation = recording.Disambiguation;

            Relationships = recording.Relationships.Select(x => new RelationshipViewModel(x));
        }
 static void WriteReviews(RecordingDto recordingDto, RecordingDataSet.Recording recording)
 {
     recordingDto.reviews = new ReviewDto[recording.GetReviews().Length];
     int index = 0;
     foreach (RecordingDataSet.Review review in recording.GetReviews())
     {
         recordingDto.reviews[index++] = WriteReview(review);
     }
 }
Exemple #7
0
    public void ReviewAddedToRecording()
    {
        int       beforeCount = Recording.GetReviews().Length;
        ReviewDto dto         = service.AddReview(reviewerName, reviewContent, rating,
                                                  Recording.Id);

        RecordingDto recordingDto = service.FindByRecordingId(Recording.Id);

        Assert.AreEqual(beforeCount + 1, recordingDto.reviews.Length);
    }
 // Intelligent mappings..may be better somewhere else?
 public static void WriteTotalRuntime(RecordingDto dto, RecordingDataSet.Recording recording)
 {
     int runTime = 0;
     foreach (RecordingDataSet.Track track in recording.GetTracks())
     {
         runTime += track.Duration;
     }
     dto.totalRunTimeSpecified = true;
     dto.totalRunTime = runTime;
 }
        private static void WriteTotalRuntime(RecordingDto dto,
                                              RecordingDataSet.Recording recording)
        {
            int runTime = 0;

            foreach (RecordingDataSet.Track track in recording.GetTracks())
            {
                runTime += track.Duration;
            }

            dto.totalRunTime = FormatDuration(runTime);
        }
        WriteTracks(RecordingDto recordingDto,
                    RecordingDataSet.Recording recording)
        {
            recordingDto.tracks = new TrackDto[recording.GetTracks().Length];

            int index = 0;

            foreach (RecordingDataSet.Track track in recording.GetTracks())
            {
                recordingDto.tracks[index++] = WriteTrack(track);
            }
        }
        private static void WriteReviews(RecordingDto recordingDto,
                                         RecordingDataSet.Recording recording)
        {
            recordingDto.reviews =
                new ReviewDto[recording.GetReviews().Length];

            int index = 0;

            foreach (RecordingDataSet.Review review in recording.GetReviews())
            {
                recordingDto.reviews[index++] = WriteReview(review);
            }
        }
Exemple #12
0
        public IRecordingDto Build(Recording recording, string accountUrl, TimeZoneInfo timeZone)
        {
            var item = new RecordingDto(recording, accountUrl, timeZone);

            if (_returnInitialRecordingDuration)
            {
                return(item);
            }

            var t = recording.GetActualDuration();

            item.Duration = (t == null) ? null : $"{(t.Value.Days * 24 + t.Value.Hours):D2}:{t.Value.Minutes:D2}:{t.Value.Seconds:D2}";
            return(item);
        }
Exemple #13
0
        public static RecordingDto CreateRecordingDto(long id)
        {
            string selectCmd = String.Format("select * from recording where id = {0}", id);

            //Open connection here.
            //Fill up command object here using DTO.

            //Create the dto here...
            RecordingDto dto = new RecordingDto();

            //Call command.Fill to load data here...

            return(dto);
        }
        public static RecordingDto WriteDto(RecordingDataSet.Recording recording)
        {
            RecordingDto dto = new RecordingDto();
            dto.id = recording.Id;
            dto.title = recording.Title;

            dto.releaseDate = recording.ReleaseDate.ToShortDateString();
            dto.artistName = recording.Artist.Name;
            dto.labelName = recording.Label.Name;

            WriteTracks(dto, recording);
            WriteTotalRuntime(dto, recording);
            WriteReviews(dto, recording);
            WriteAverageRating(dto, recording);
            return dto;
        }
 private static void WriteAverageRating(RecordingDto recordingDto,
                                        RecordingDataSet.Recording recording)
 {
     if (recording.GetReviews().Length == 0)
     {
         recordingDto.averageRating = 0;
     }
     else
     {
         int totalRating = 0;
         foreach (RecordingDataSet.Review review in recording.GetReviews())
         {
             totalRating += review.Rating;
         }
         recordingDto.averageRating = totalRating / recording.GetReviews().Length;
     }
 }
 static void WriteAverageRating(RecordingDto recordingDto, RecordingDataSet.Recording recording)
 {
     recordingDto.averageRatingSpecified = true;
     if (recording.GetReviews().Length == 0)
     {
         recordingDto.averageRating = 0;
     }
     else
     {
         int totalRating = 0;
         foreach (RecordingDataSet.Review review in recording.GetReviews())
         {
             totalRating += review.Rating;
         }
         recordingDto.averageRating = totalRating/recording.GetReviews().Length;
     }
 }
        WriteDto(RecordingDataSet.Recording recording)
        {
            RecordingDto dto = new RecordingDto();

            dto.id          = recording.Id;
            dto.title       = recording.Title;
            dto.releaseDate = recording.ReleaseDate.ToShortDateString();
            dto.artistName  = recording.Artist.Name;
            dto.labelName   = recording.Label.Name;

            WriteTracks(dto, recording);
            WriteTotalRuntime(dto, recording);

            WriteReviews(dto, recording);
            WriteAverageRating(dto, recording);

            return(dto);
        }
Exemple #18
0
    protected override ArrayList GetDtos(SearchCriteria criteria)
    {
        ArrayList results = new ArrayList();

        if (criteria.id != 0)
        {
            RecordingDto dto = new RecordingDto();
            dto.id = criteria.id;

            results.Add(dto);
        }
        else if (criteria.artistName != null)
        {
            RecordingDto dto = new RecordingDto();
            dto.artistName = criteria.artistName;
            results.Add(dto);
            results.Add(dto);
        }

        return(results);
    }
        public void InvalidId()
        {
            RecordingDto nullDto = service.FindByRecordingId(2);

            Assert.IsNull(nullDto, "should be null");
        }
 public void SetUp()
 {
     recording = InMemoryRecordingBuilder.Make();
     service   = new StubCatalogService(recording);
     dto       = service.FindByRecordingId(recording.Id);
 }
 public override void CustomizeRecording()
 {
     service = new DatabaseCatalogService();
     dto     = service.FindByRecordingId(Recording.Id);
 }
 public RecordingDisplayAdapter(RecordingDto dto)
 {
     this.dto = dto;
 }
Exemple #23
0
 public void SetUp()
 {
     recording = InMemoryRecordingBuilder.Make();
     dto       = RecordingAssembler.WriteDto(recording);
 }
 public void SetUp()
 {
     recording = InMemoryRecordingBuilder.Make();
     dto = RecordingAssembler.WriteDto(recording);
 }
Exemple #25
0
 static void Main(string[] args)
 {
     RecordingDto dtoObject = Assembler.CreateRecordingDto(4);
 }
Exemple #26
0
 public void FindByRecordingId(long id)
 {
     recording = gateway.FindByRecordingId(id);
 }
 static void WriteTracks(RecordingDto recordingDto, RecordingDataSet.Recording recording)
 {
     recordingDto.tracks = new TrackDto[recording.GetTracks().Length];
     int index = 0;
     foreach (RecordingDataSet.Track track in recording.GetTracks())
     {
         //recordingDto.tracks[index++] = new TrackDto();
         recordingDto.tracks[index++] = WriteTrack(track);
     }
 }