Пример #1
0
        public void InsertCapeReviewTest()
        {
            //// 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.InsertCape(capeReview, ref errors));

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

            //// Assert
            mockRepository.Verify(x => x.InsertCape(capeReview, ref errors), Times.Once());
        }
Пример #2
0
        public void InsertCapeReviewErrorTest1()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<ICapeReviewRepository>();
            var capeReviewService = new CapeReviewService(mockRepository.Object);

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

            //// Assert cant be null CapeReview object
            Assert.AreEqual(1, errors.Count);
        }
Пример #3
0
        public void InsertCapeReviewErrorTest4()
        {
            //// 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.InsertCapeReview(capeReview, ref errors);

            //// Assert last name cannot be empty
            Assert.AreEqual(1, errors.Count);
        }
Пример #4
0
        public string InsertCapeReview(CapeReview cr)
        {
            var errors = new List<string>();
            var repository = new CapeReviewRepository(this.entities);
            var service = new CapeReviewService(repository);
            service.InsertCapeReview(cr, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "Failed cape review insert";
        }