예제 #1
0
        public void get_all_courses()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);
            //Act
            var x = service.GetAllCourses();

            //Assert
            Assert.AreEqual(x.Count(), queries.Select(p => p).ToList().Count());
        }
        public async Task get_course_by_authorId_async()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var x = await service.GetByAuthorIdAsync(1);

            //Assert
            Assert.AreEqual(1, x.Count());
        }
        public async Task get_course_by_id_async()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var x = await service.GetByIdAsync("123");

            //Assert
            Assert.AreEqual(x.Id, "123");
        }
예제 #4
0
        public void get_course_by_authorId()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var x = service.GetByAuthorId(2).FirstOrDefault();

            //Assert
            Assert.AreEqual(2, x.AuthorId);
        }
예제 #5
0
        public void get_course_by_id()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var x = service.GetById("123");

            //Assert
            Assert.AreEqual(x.Id, "123");
        }
        public async Task get_all_courses_async()
        {
            //Arrage
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var q = await service.GetAllCoursesAsync();

            //Assert
            Assert.AreEqual(courses.Select(p => p).ToList().Count(), q.Count());
        }
예제 #7
0
        public void remove_course_by_id()
        {
            mockSetItem = new Mock <DbSet <CourseItemDB> >();
            mockContext.Setup(x => x.CourseItems).Returns(mockSetItem.Object);
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            //Act
            var result = service.DeleteById("123");

            //Assert
            Assert.IsTrue(result);
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
            mockSet.Verify(m => m.Remove(It.IsAny <CourseDB>()), Times.Once());
            mockSetItem.Verify(m => m.RemoveRange(It.IsAny <IEnumerable <CourseItemDB> >()), Times.Once());
        }
예제 #8
0
        public void add_course()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            LearningCourseDTO lc = new LearningCourseDTO
            {
                Name     = "Course",
                Id       = "33",
                Category = 2,
                Cost     = 10,
                Language = "EN"
            };
            //Act
            var x = service.AddNoIndex(lc);

            //Assert
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
예제 #9
0
        public void update_course()
        {
            var DbService        = new CourseDbService(mockContext.Object);
            var mockLogicService = new Mock <LearningCourseService>();
            var service          = new LearningCourseService(mapper, DbService);

            LearningCourseDTO lc = new LearningCourseDTO
            {
                Name     = "Course",
                Id       = "123",
                Category = 2,
                Cost     = 10,
                Language = "EN"
            };
            //Act
            var x = service.UpdateNoIndex(lc);

            //Assert
            Assert.AreEqual(queries.First().Id, lc.Id);
            Assert.AreEqual(queries.Count(), queries.Count());
        }