public virtual ApiStudentXFamilyResponseModel MapBOToModel( BOStudentXFamily boStudentXFamily) { var model = new ApiStudentXFamilyResponseModel(); model.SetProperties(boStudentXFamily.Id, boStudentXFamily.FamilyId, boStudentXFamily.StudentId); return(model); }
public void MapResponseToRequest() { var mapper = new ApiStudentXFamilyModelMapper(); var model = new ApiStudentXFamilyResponseModel(); model.SetProperties(1, 1, 1); ApiStudentXFamilyRequestModel response = mapper.MapResponseToRequest(model); response.FamilyId.Should().Be(1); response.StudentId.Should().Be(1); }
public void MapBOToModel() { var mapper = new BOLStudentXFamilyMapper(); BOStudentXFamily bo = new BOStudentXFamily(); bo.SetProperties(1, 1, 1); ApiStudentXFamilyResponseModel response = mapper.MapBOToModel(bo); response.FamilyId.Should().Be(1); response.Id.Should().Be(1); response.StudentId.Should().Be(1); }
public async virtual Task <IActionResult> Get(int id) { ApiStudentXFamilyResponseModel response = await this.StudentXFamilyService.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 <IStudentXFamilyRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <StudentXFamily>(null)); var service = new StudentXFamilyService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.StudentXFamilyModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLStudentXFamilyMapperMock, mock.DALMapperMockFactory.DALStudentXFamilyMapperMock); ApiStudentXFamilyResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Create_Errors() { StudentXFamilyControllerMockFacade mock = new StudentXFamilyControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiStudentXFamilyResponseModel> >(new FluentValidation.Results.ValidationResult()); var mockRecord = new ApiStudentXFamilyResponseModel(); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiStudentXFamilyRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiStudentXFamilyResponseModel> >(mockResponse.Object)); StudentXFamilyController controller = new StudentXFamilyController(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 ApiStudentXFamilyRequestModel()); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiStudentXFamilyRequestModel>())); }
public async void All_Exists() { StudentXFamilyControllerMockFacade mock = new StudentXFamilyControllerMockFacade(); var record = new ApiStudentXFamilyResponseModel(); var records = new List <ApiStudentXFamilyResponseModel>(); records.Add(record); mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); StudentXFamilyController controller = new StudentXFamilyController(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 <ApiStudentXFamilyResponseModel>; 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 <ApiStudentXFamilyRequestModel> patch) { ApiStudentXFamilyResponseModel record = await this.StudentXFamilyService.Get(id); if (record == null) { return(this.StatusCode(StatusCodes.Status404NotFound)); } else { ApiStudentXFamilyRequestModel model = await this.PatchModel(id, patch); UpdateResponse <ApiStudentXFamilyResponseModel> result = await this.StudentXFamilyService.Update(id, model); if (result.Success) { return(this.Ok(result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } } }
public async void TestGet() { ApiStudentXFamilyResponseModel response = await this.Client.StudentXFamilyGetAsync(1); response.Should().NotBeNull(); }