Пример #1
0
        public async Task ReturnsCourseById()
        {
            // Arrange
            var data = this.GetData();

            var course = new Course();

            var mockedSet = new Mock <DbSet <Course> >();

            mockedSet.As <IQueryable <Course> >().Setup(m => m.Provider).Returns(data.Provider);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.Expression).Returns(data.Expression);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            mockedSet.Setup(a => a.FindAsync(It.IsAny <object>())).ReturnsAsync(course);

            var contextMock = new Mock <ApplicationDbContext>();

            contextMock.Setup(c => c.Courses).Returns(mockedSet.Object);

            var service = new AssignmentService(contextMock.Object);

            // Act
            var result = await service.GetById(1);

            // Assert
            Assert.AreEqual(course, result);
        }
Пример #2
0
        public ActionResult Update(int id)
        {
            Assignment entity = service.GetById(id);

            var model = new AssignmentViewModel()
            {
                Id          = entity.Id,
                Title       = entity.Title,
                Description = entity.Description,
                CreatedAt   = entity.CreatedAt,
                UpdatedAt   = entity.UpdatedAt,
                IsDone      = entity.IsDone
            };

            return(View(model));
        }
Пример #3
0
        public void GetByIdGetsAssignmentWithTheGivenId()
        {
            BaseServiceTests.Initialize();

            var id = this.dbFixture.dbContext.Assignments
                     .Where(l => l.IsDeleted == false).Select(l => l.Id).First();

            var repository = new DbRepository <Assignment>(this.dbFixture.dbContext);
            var service    = new AssignmentService(repository);

            var result = service.GetById(id);

            Assert.Equal(id, result.Id);
        }
Пример #4
0
        public void GetByIdMenu()
        {
            bool ContinueOrExit = true;

            do
            {
                Console.WriteLine("If u want to get a student by ID from the private school data base write 1 in console");
                Console.WriteLine("If u want to get a trainer by ID from the private school data base write 2 in console");
                Console.WriteLine("If u want to get a course by ID from the private school data base write 3 in console");
                Console.WriteLine("If u want to get a assignment by ID from the private school data base write 4 in console");
                Console.WriteLine("If u want to get a relationship between student and course by ID from the to the private school data base write 5 in console");
                Console.WriteLine("If u want to get a relationship between trainer and course by ID from the private school data base write 6 in console");
                Console.WriteLine("If u want to get a relationship between assignment and course by ID from the private school data base write 7 in console");
                Console.WriteLine("\nIf u want to return to Bonus Menu write 0 from keyboard\n");
                string userInput = Console.ReadLine();
                ContinueOrExit = CheckToContinueOrExit(userInput);
                switch (userInput)
                {
                case "1":
                    Console.Clear();
                    studentService.GetById();
                    break;

                case "2":
                    Console.Clear();
                    trainerService.GetById();
                    break;

                case "3":
                    Console.Clear();
                    courseService.GetById();
                    break;

                case "4":
                    Console.Clear();
                    assignmentService.GetById();
                    break;

                case "5":
                    Console.Clear();
                    watchService.GetById();
                    break;

                case "6":
                    Console.Clear();
                    teachService.GetById();
                    break;

                case "7":
                    Console.Clear();
                    assignService.GetById();
                    break;

                case "0":
                    Console.Clear();
                    break;

                default:
                    Console.Clear();
                    GetByIdMenu();
                    break;
                }
            } while (ContinueOrExit);
        }