Ejemplo n.º 1
0
        public async Task Update_Subject_State_On_Create(Mock <IAuthorizationService> authorizationService, Mock <IStateService> stateService, LessonRequest request)
        {
            stateService.Setup(x => x.UpdateSubjectState(It.IsAny <Guid>(), It.IsAny <CancellationToken>()));

            var context     = TestSetup.SetupContext();
            var httpContext = TestSetup.SetupHttpContext();

            var service = new LessonService(context, httpContext, authorizationService.Object, stateService.Object);
            await service.Create(request);

            stateService.VerifyAll();
        }
Ejemplo n.º 2
0
        public async Task Create_ReturnsNewLesson()
        {
            //Arrange
            var lesson    = AutoFaker.Generate <Lesson>();
            var subjectId = AutoFaker.Generate <int>();

            _askmeRepository.Setup(x => x.AddLesson(It.IsAny <Lesson>(), It.IsAny <int>()))
            .ReturnsAsync(lesson);

            //Act
            var result = await _sut.Create(lesson, subjectId);

            //Assert
            result.Should().BeOfType <Lesson>();
            result.Should().BeEquivalentTo(lesson);
        }
Ejemplo n.º 3
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <ILessonRepository>();
            var model = new ApiLessonRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Lesson>())).Returns(Task.FromResult(new Lesson()));
            var service = new LessonService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.LessonModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLLessonMapperMock,
                                            mock.DALMapperMockFactory.DALLessonMapperMock,
                                            mock.BOLMapperMockFactory.BOLLessonXStudentMapperMock,
                                            mock.DALMapperMockFactory.DALLessonXStudentMapperMock,
                                            mock.BOLMapperMockFactory.BOLLessonXTeacherMapperMock,
                                            mock.DALMapperMockFactory.DALLessonXTeacherMapperMock);

            CreateResponse <ApiLessonResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.LessonModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiLessonRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Lesson>()));
        }
Ejemplo n.º 4
0
 public async Task <Lesson> Create([FromQuery] LessonModel lessonModel)
 {
     return(await _lessonService.Create(lessonModel));
 }