public virtual ApiTransactionStatusResponseModel MapBOToModel( BOTransactionStatus boTransactionStatus) { var model = new ApiTransactionStatusResponseModel(); model.SetProperties(boTransactionStatus.Id, boTransactionStatus.Name); return(model); }
public void MapResponseToRequest() { var mapper = new ApiTransactionStatusModelMapper(); var model = new ApiTransactionStatusResponseModel(); model.SetProperties(1, "A"); ApiTransactionStatusRequestModel response = mapper.MapResponseToRequest(model); response.Name.Should().Be("A"); }
public void MapBOToModel() { var mapper = new BOLTransactionStatusMapper(); BOTransactionStatus bo = new BOTransactionStatus(); bo.SetProperties(1, "A"); ApiTransactionStatusResponseModel response = mapper.MapBOToModel(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public async virtual Task <IActionResult> Get(int id) { ApiTransactionStatusResponseModel response = await this.TransactionStatusService.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 <ITransactionStatusRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <TransactionStatus>(null)); var service = new TransactionStatusService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.TransactionStatusModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLTransactionStatusMapperMock, mock.DALMapperMockFactory.DALTransactionStatusMapperMock, mock.BOLMapperMockFactory.BOLTransactionMapperMock, mock.DALMapperMockFactory.DALTransactionMapperMock); ApiTransactionStatusResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Create_Errors() { TransactionStatusControllerMockFacade mock = new TransactionStatusControllerMockFacade(); var mockResponse = new Mock <CreateResponse <ApiTransactionStatusResponseModel> >(new FluentValidation.Results.ValidationResult()); var mockRecord = new ApiTransactionStatusResponseModel(); mockResponse.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiTransactionStatusRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiTransactionStatusResponseModel> >(mockResponse.Object)); TransactionStatusController controller = new TransactionStatusController(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 ApiTransactionStatusRequestModel()); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiTransactionStatusRequestModel>())); }
public async void All_Exists() { TransactionStatusControllerMockFacade mock = new TransactionStatusControllerMockFacade(); var record = new ApiTransactionStatusResponseModel(); var records = new List <ApiTransactionStatusResponseModel>(); records.Add(record); mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); TransactionStatusController controller = new TransactionStatusController(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 <ApiTransactionStatusResponseModel>; 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 <ApiTransactionStatusRequestModel> patch) { ApiTransactionStatusResponseModel record = await this.TransactionStatusService.Get(id); if (record == null) { return(this.StatusCode(StatusCodes.Status404NotFound)); } else { ApiTransactionStatusRequestModel model = await this.PatchModel(id, patch); UpdateResponse <ApiTransactionStatusResponseModel> result = await this.TransactionStatusService.Update(id, model); if (result.Success) { return(this.Ok(result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } } }
public async void TestGet() { ApiTransactionStatusResponseModel response = await this.Client.TransactionStatusGetAsync(1); response.Should().NotBeNull(); }