public virtual ApiInterruptionResponseModel MapBOToModel(
            BOInterruption boInterruption)
        {
            var model = new ApiInterruptionResponseModel();

            model.SetProperties(boInterruption.Id, boInterruption.Created, boInterruption.EnvironmentId, boInterruption.JSON, boInterruption.ProjectId, boInterruption.RelatedDocumentIds, boInterruption.ResponsibleTeamIds, boInterruption.Status, boInterruption.TaskId, boInterruption.TenantId, boInterruption.Title);

            return(model);
        }
Ejemplo n.º 2
0
        public async virtual Task <IActionResult> Get(string id)
        {
            ApiInterruptionResponseModel response = await this.InterruptionService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
Ejemplo n.º 3
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IInterruptionRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <Interruption>(null));
            var service = new InterruptionService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.InterruptionModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLInterruptionMapperMock,
                                                  mock.DALMapperMockFactory.DALInterruptionMapperMock);

            ApiInterruptionResponseModel response = await service.Get(default(string));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiInterruptionModelMapper();
            var model  = new ApiInterruptionResponseModel();

            model.SetProperties("A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", "A", "A", "A", "A");
            ApiInterruptionRequestModel response = mapper.MapResponseToRequest(model);

            response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.EnvironmentId.Should().Be("A");
            response.JSON.Should().Be("A");
            response.ProjectId.Should().Be("A");
            response.RelatedDocumentIds.Should().Be("A");
            response.ResponsibleTeamIds.Should().Be("A");
            response.Status.Should().Be("A");
            response.TaskId.Should().Be("A");
            response.TenantId.Should().Be("A");
            response.Title.Should().Be("A");
        }
Ejemplo n.º 5
0
        public void MapBOToModel()
        {
            var            mapper = new BOLInterruptionMapper();
            BOInterruption bo     = new BOInterruption();

            bo.SetProperties("A", DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", "A", "A", "A", "A");
            ApiInterruptionResponseModel response = mapper.MapBOToModel(bo);

            response.Created.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.EnvironmentId.Should().Be("A");
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.ProjectId.Should().Be("A");
            response.RelatedDocumentIds.Should().Be("A");
            response.ResponsibleTeamIds.Should().Be("A");
            response.Status.Should().Be("A");
            response.TaskId.Should().Be("A");
            response.TenantId.Should().Be("A");
            response.Title.Should().Be("A");
        }
        public async void Create_Errors()
        {
            InterruptionControllerMockFacade mock = new InterruptionControllerMockFacade();

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

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

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiInterruptionRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiInterruptionResponseModel> >(mockResponse.Object));
            InterruptionController controller = new InterruptionController(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 ApiInterruptionRequestModel());

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

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            InterruptionController controller = new InterruptionController(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 <ApiInterruptionResponseModel>;

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Ejemplo n.º 8
0
        public virtual async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <ApiInterruptionRequestModel> patch)
        {
            ApiInterruptionResponseModel record = await this.InterruptionService.Get(id);

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

                UpdateResponse <ApiInterruptionResponseModel> result = await this.InterruptionService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Ejemplo n.º 9
0
        public async void TestGet()
        {
            ApiInterruptionResponseModel response = await this.Client.InterruptionGetAsync("A");

            response.Should().NotBeNull();
        }