public virtual ApiPasswordResponseModel MapBOToModel(
            BOPassword boPassword)
        {
            var model = new ApiPasswordResponseModel();

            model.SetProperties(boPassword.BusinessEntityID, boPassword.ModifiedDate, boPassword.PasswordHash, boPassword.PasswordSalt, boPassword.Rowguid);

            return(model);
        }
Ejemplo n.º 2
0
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiPasswordResponseModel response = await client.PasswordGetAsync(1);

            response.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiPasswordResponseModel response = await this.PasswordService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
Ejemplo n.º 4
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiPasswordModelMapper();
            var model  = new ApiPasswordResponseModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiPasswordRequestModel response = mapper.MapResponseToRequest(model);

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PasswordHash.Should().Be("A");
            response.PasswordSalt.Should().Be("A");
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Ejemplo n.º 5
0
        public void MapBOToModel()
        {
            var        mapper = new BOLPasswordMapper();
            BOPassword bo     = new BOPassword();

            bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiPasswordResponseModel response = mapper.MapBOToModel(bo);

            response.BusinessEntityID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PasswordHash.Should().Be("A");
            response.PasswordSalt.Should().Be("A");
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Ejemplo n.º 6
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IPasswordRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Password>(null));
            var service = new PasswordService(mock.LoggerMock.Object,
                                              mock.RepositoryMock.Object,
                                              mock.ModelValidatorMockFactory.PasswordModelValidatorMock.Object,
                                              mock.BOLMapperMockFactory.BOLPasswordMapperMock,
                                              mock.DALMapperMockFactory.DALPasswordMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Ejemplo n.º 7
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            ApiPasswordResponseModel model = await client.PasswordGetAsync(1);

            ApiPasswordModelMapper mapper = new ApiPasswordModelMapper();

            UpdateResponse <ApiPasswordResponseModel> updateResponse = await client.PasswordUpdateAsync(model.BusinessEntityID, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
Ejemplo n.º 8
0
        public async void Create_Errors()
        {
            PasswordControllerMockFacade mock = new PasswordControllerMockFacade();

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

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

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

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiPasswordRequestModel>()));
        }
Ejemplo n.º 9
0
        public async void All_Exists()
        {
            PasswordControllerMockFacade mock = new PasswordControllerMockFacade();
            var record  = new ApiPasswordResponseModel();
            var records = new List <ApiPasswordResponseModel>();

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

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

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

                UpdateResponse <ApiPasswordResponseModel> result = await this.PasswordService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Ejemplo n.º 11
0
        public async void TestGet()
        {
            ApiPasswordResponseModel response = await this.Client.PasswordGetAsync(1);

            response.Should().NotBeNull();
        }