Example #1
0
        public async Task WhenAsync(MergePatchRoleDto c)
        {
            var idObj         = (c as IMergePatchRole).RoleId;
            var uriParameters = new RoleUriParameters();

            uriParameters.Id = idObj;

            var req  = new RolePatchRequest(uriParameters, (MergePatchRoleDto)c);
            var resp = await _ramlClient.Role.Patch(req);

            RoleProxyUtils.ThrowOnHttpResponseError(resp);
        }
Example #2
0
        public async Task Put_NonExistingRole_ReturnsNotFoundResult()
        {
            var rolePutModel = new RolePatchRequest {
                Description = "desc"
            };

            this.roleManagerMock.Setup(r => r.FindByNameAsync(It.IsAny <string>())).ReturnsAsync((ApplicationRole)null);

            var controller = new RoleController(this.roleManagerMock.Object, this.userManagerMock.Object, this.localizationMock.Object, this.mapperMock.Object);
            var response   = await controller.Patch(null, rolePutModel).ConfigureAwait(false);

            Assert.IsAssignableFrom <NotFoundResult>(response);
        }
Example #3
0
        public async Task Patch_ValidModel_ReturnsOkResult()
        {
            string roleName        = "admin";
            string roleDescription = "admin role desc";

            RolePatchRequest model = new RolePatchRequest {
                Description = roleDescription
            };

            this.roleManagerMock.Setup(r => r.FindByNameAsync("admin")).ReturnsAsync(new ApplicationRole());
            this.roleManagerMock.Setup(r => r.UpdateAsync(It.IsAny <ApplicationRole>())).ReturnsAsync(IdentityResult.Success);

            var controller = new RoleController(this.roleManagerMock.Object, this.userManagerMock.Object, this.localizationMock.Object, this.mapperMock.Object);

            controller.BindViewModel(model);

            var response = await controller.Patch(roleName, model).ConfigureAwait(false);

            Assert.IsAssignableFrom <OkObjectResult>(response);
        }