public void UpdateCapeReviewTest()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<ICapeReviewRepository>();
            var capeReviewService = new CapeReviewService(mockRepository.Object);
            var capeReview = new CapeReview { CapeId = 1, CourseId = 2, CourseRating = 3, InstructorId = 4, InstructorRating = 5, Summary = "hello" };

            mockRepository.Setup(x => x.UpdateCapeReview(capeReview, ref errors));

            //// Act
            capeReviewService.UpdateCapeReview(capeReview, ref errors);

            //// Assert
            mockRepository.Verify(x => x.UpdateCapeReview(capeReview, ref errors), Times.Once());
        }
        public void UpdateCapeReviewErrorTest1()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<ICapeReviewRepository>();
            var capeReviewService = new CapeReviewService(mockRepository.Object);

            //// Act
            capeReviewService.UpdateCapeReview(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
        public void UpdateCapeReviewErrorTest4()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<ICapeReviewRepository>();
            var capeReviewService = new CapeReviewService(mockRepository.Object);
            var capeReview = new CapeReview { CapeId = 1, CourseId = 2, CourseRating = 3, InstructorId = 4, InstructorRating = 5, Summary = null };

            //// Act
            capeReviewService.UpdateCapeReview(capeReview, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Beispiel #4
0
        public string UpdateCapeReview(CapeReview cr)
        {
            var errors = new List<string>();
            var repository = new CapeReviewRepository(this.entities);
            var service = new CapeReviewService(repository);
            service.UpdateCapeReview(cr, ref errors);

            if (errors.Count == 0)
            {
                return "successful cape review insert";
            }

            return "Failed cape review insert";
        }