Пример #1
0
        public async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            var createModel = new ApiPipelineStepNoteRequestModel();

            createModel.SetProperties(1, "B", 1);
            CreateResponse <ApiPipelineStepNoteResponseModel> createResult = await client.PipelineStepNoteCreateAsync(createModel);

            createResult.Success.Should().BeTrue();

            ApiPipelineStepNoteResponseModel getResponse = await client.PipelineStepNoteGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.PipelineStepNoteDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();

            ApiPipelineStepNoteResponseModel verifyResponse = await client.PipelineStepNoteGetAsync(2);

            verifyResponse.Should().BeNull();
        }
Пример #2
0
        public virtual ApiPipelineStepNoteResponseModel MapBOToModel(
            BOPipelineStepNote boPipelineStepNote)
        {
            var model = new ApiPipelineStepNoteResponseModel();

            model.SetProperties(boPipelineStepNote.Id, boPipelineStepNote.EmployeeId, boPipelineStepNote.Note, boPipelineStepNote.PipelineStepId);

            return(model);
        }
Пример #3
0
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiPipelineStepNoteResponseModel response = await client.PipelineStepNoteGetAsync(1);

            response.Should().NotBeNull();
        }
Пример #4
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiPipelineStepNoteModelMapper();
            var model  = new ApiPipelineStepNoteResponseModel();

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

            response.EmployeeId.Should().Be(1);
            response.Note.Should().Be("A");
            response.PipelineStepId.Should().Be(1);
        }
Пример #5
0
        public void MapBOToModel()
        {
            var mapper            = new BOLPipelineStepNoteMapper();
            BOPipelineStepNote bo = new BOPipelineStepNote();

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

            response.EmployeeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Note.Should().Be("A");
            response.PipelineStepId.Should().Be(1);
        }
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiPipelineStepNoteResponseModel response = await this.PipelineStepNoteService.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<IPipelineStepNoteRepository>();
			mock.RepositoryMock.Setup(x => x.Get(It.IsAny<int>())).Returns(Task.FromResult<PipelineStepNote>(null));
			var service = new PipelineStepNoteService(mock.LoggerMock.Object,
			                                          mock.RepositoryMock.Object,
			                                          mock.ModelValidatorMockFactory.PipelineStepNoteModelValidatorMock.Object,
			                                          mock.BOLMapperMockFactory.BOLPipelineStepNoteMapperMock,
			                                          mock.DALMapperMockFactory.DALPipelineStepNoteMapperMock);

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

			response.Should().BeNull();
			mock.RepositoryMock.Verify(x => x.Get(It.IsAny<int>()));
		}
Пример #8
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiPipelineStepNoteResponseModel model = await client.PipelineStepNoteGetAsync(1);

            ApiPipelineStepNoteModelMapper mapper = new ApiPipelineStepNoteModelMapper();

            UpdateResponse <ApiPipelineStepNoteResponseModel> updateResponse = await client.PipelineStepNoteUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
        public async void Create_Errors()
        {
            PipelineStepNoteControllerMockFacade mock = new PipelineStepNoteControllerMockFacade();

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

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

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

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

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

            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 <ApiPipelineStepNoteRequestModel> patch)
        {
            ApiPipelineStepNoteResponseModel record = await this.PipelineStepNoteService.Get(id);

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

                UpdateResponse <ApiPipelineStepNoteResponseModel> result = await this.PipelineStepNoteService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Пример #12
0
        public async void TestGet()
        {
            ApiPipelineStepNoteResponseModel response = await this.Client.PipelineStepNoteGetAsync(1);

            response.Should().NotBeNull();
        }