public virtual ApiLessonStatusResponseModel MapBOToModel(
            BOLessonStatus boLessonStatus)
        {
            var model = new ApiLessonStatusResponseModel();

            model.SetProperties(boLessonStatus.Id, boLessonStatus.Name, boLessonStatus.StudioId);

            return(model);
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiLessonStatusModelMapper();
            var model  = new ApiLessonStatusResponseModel();

            model.SetProperties(1, "A", 1);
            ApiLessonStatusRequestModel response = mapper.MapResponseToRequest(model);

            response.Name.Should().Be("A");
            response.StudioId.Should().Be(1);
        }
        public void MapBOToModel()
        {
            var            mapper = new BOLLessonStatusMapper();
            BOLessonStatus bo     = new BOLessonStatus();

            bo.SetProperties(1, "A", 1);
            ApiLessonStatusResponseModel response = mapper.MapBOToModel(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StudioId.Should().Be(1);
        }
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiLessonStatusResponseModel response = await this.LessonStatusService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <ILessonStatusRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <LessonStatus>(null));
            var service = new LessonStatusService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.LessonStatusModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLLessonStatusMapperMock,
                                                  mock.DALMapperMockFactory.DALLessonStatusMapperMock,
                                                  mock.BOLMapperMockFactory.BOLLessonMapperMock,
                                                  mock.DALMapperMockFactory.DALLessonMapperMock);

            ApiLessonStatusResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public async void Create_Errors()
        {
            LessonStatusControllerMockFacade mock = new LessonStatusControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiLessonStatusResponseModel> >(new FluentValidation.Results.ValidationResult());
            var mockRecord   = new ApiLessonStatusResponseModel();

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiLessonStatusRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiLessonStatusResponseModel> >(mockResponse.Object));
            LessonStatusController controller = new LessonStatusController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Create(new ApiLessonStatusRequestModel());

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiLessonStatusRequestModel>()));
        }
        public async void All_Exists()
        {
            LessonStatusControllerMockFacade mock = new LessonStatusControllerMockFacade();
            var record  = new ApiLessonStatusResponseModel();
            var records = new List <ApiLessonStatusResponseModel>();

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            LessonStatusController controller = new LessonStatusController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.All(1000, 0);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var items = (response as OkObjectResult).Value as List <ApiLessonStatusResponseModel>;

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiLessonStatusRequestModel> patch)
        {
            ApiLessonStatusResponseModel record = await this.LessonStatusService.Get(id);

            if (record == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                ApiLessonStatusRequestModel model = await this.PatchModel(id, patch);

                UpdateResponse <ApiLessonStatusResponseModel> result = await this.LessonStatusService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Example #9
0
        public async void TestGet()
        {
            ApiLessonStatusResponseModel response = await this.Client.LessonStatusGetAsync(1);

            response.Should().NotBeNull();
        }