public async Task GetAuthenticationModeAsync_WithTestGuid_ReturnsCorrectResult()
        {
            // Arrange
            var testGuid = Guid.NewGuid();
            var testName = "TestAuthenticationModeName";

            ldapAuthenticationModeService.GetByIdAsync(testGuid).Returns(new LdapAuthenticationMode {
                Uuid = testGuid, Name = testName
            });

            var controller = new LdapAuthenticationModeController(ldapAuthenticationModeService, orderByHelper, paginationHelper, mapper);

            // Act
            IActionResult actionResult = await controller.GetLdapAuthenticationModeAsync(testGuid);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);

            var authenticationMode = okResult.Value as LdapAuthenticationMode;

            Assert.NotNull(authenticationMode);
            Assert.True(authenticationMode.Uuid == testGuid, $"Retrieved Id {authenticationMode.Uuid} not the same as sample id {testGuid}.");
            Assert.True(authenticationMode.Name == testName, $"Retrieved Name {authenticationMode.Name} not the same as sample id {testName}.");
        }
Example #2
0
        public override async Task <IActionResult> GetLdapAuthenticationModeAsync([FromRoute, Required] Guid ldapAuthenticationModeId)
        {
            var authenticationMode = await authenticationModeService.GetByIdAsync(ldapAuthenticationModeId);

            if (authenticationMode == null)
            {
                return(NotFound());
            }

            return(Ok(authenticationMode));
        }