public void AddReviewWithoutExistingReviewer() { int rating = 1; string content = "Review content"; RecordingDataSet.Review review = Catalog.AddReview(recordingDataSet, reviewerName, content, rating, Recording.Id); Assert.IsNotNull(review); RecordingDataSet loadedFromDBDataSet = new RecordingDataSet(); RecordingDataSet.Recording loadedFromDBRecording = Catalog.FindByRecordingId(loadedFromDBDataSet, Recording.Id); Assert.AreEqual(1, loadedFromDBRecording.GetReviews().Length); RecordingDataSet.Review loadedFromDBReview = loadedFromDBRecording.GetReviews()[0]; ReviewGateway reviewGateway = new ReviewGateway(Connection); reviewGateway.Delete(loadedFromDBDataSet, loadedFromDBReview.Id); ReviewerGateway ReviewerGateway = new ReviewerGateway(Connection); long reviewerId = review.ReviewerId; ReviewerGateway.Delete(recordingDataSet, reviewerId); }
public void TearDown() { artistGateway.Delete(recordingDataSet, artistId); labelGateway.Delete(recordingDataSet, labelId); genreGateway.Delete(recordingDataSet, genreId); reviewerGateway.Delete(recordingDataSet, reviewerId); reviewGateway.Delete(recordingDataSet, reviewId); trackGateway.Delete(recordingDataSet, trackId); recordingGateway.Delete(recordingDataSet, recordingId); }
public void DeleteReviewerFromDatabase() { RecordingDataSet emptyDataSet = new RecordingDataSet(); long deletedReviewerId = gateway.Insert(emptyDataSet, "Deleted Reviewer"); gateway.Delete(emptyDataSet, deletedReviewerId); RecordingDataSet.Reviewer deleletedReviewer = gateway.FindById(deletedReviewerId, emptyDataSet); Assert.IsNull(deleletedReviewer); }
public void AddTwoReviewsWithExistingReviewer() { int rating = 1; string content = "Review content"; ReviewerGateway reviewerGateway = new ReviewerGateway(Connection); long reviewerId = reviewerGateway.Insert(recordingDataSet, reviewerName); RecordingDataSet.Reviewer reviewer = reviewerGateway.FindById(reviewerId, recordingDataSet); RecordingDataSet.Review reviewOne = Catalog.AddReview(recordingDataSet, reviewerName, content, rating, Recording.Id); try { RecordingDataSet.Review reviewTwo = Catalog.AddReview(recordingDataSet, reviewerName, content, rating, Recording.Id); Assert.Fail("Expected an ExistingReviewException"); } catch (ExistingReviewException exception) { Assert.AreEqual(reviewOne.Id, exception.ExistingId); } finally { RecordingDataSet dbDataSet = new RecordingDataSet(); RecordingDataSet.Recording dbRecording = Catalog.FindByRecordingId(dbDataSet, Recording.Id); RecordingDataSet.Review[] reviews = dbRecording.GetReviews(); ReviewGateway reviewGateway = new ReviewGateway(Connection); foreach (RecordingDataSet.Review existingReview in reviews) { reviewGateway.Delete(dbDataSet, existingReview.Id); } reviewerGateway.Delete(recordingDataSet, reviewerId); } }
public void ReviewerId() { RecordingDataSet recordingDataSet = new RecordingDataSet(); ReviewGateway reviewGateway = new ReviewGateway(Connection); long reviewId = reviewGateway.Insert(recordingDataSet, 1, "Review Content"); ReviewerGateway reviewerGateway = new ReviewerGateway(Connection); long reviewerId = reviewerGateway.Insert(recordingDataSet, "Reviewer Name"); RecordingDataSet.Review review = reviewGateway.FindById(reviewId, recordingDataSet); review.ReviewerId = reviewerId; reviewGateway.Update(recordingDataSet); Assert.AreEqual(reviewerId, review.Reviewer.Id); reviewGateway.Delete(recordingDataSet, reviewId); reviewerGateway.Delete(recordingDataSet, reviewerId); }
public void TearDown() { gateway.Delete(recordingDataSet, reviewerId); }