Example #1
0
        public void BypassUserRoles_WithNullOrEmptyArray_ShouldThrow(string[] userRoles, Type expectedException)
        {
            MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(_dirMapperSvc);
            Action testAction = () =>
            {
                builder.BypassUserRoles(userRoles);
            };


            testAction.ShouldThrow(expectedException);
        }
Example #2
0
        public void BypassUserRoles_WithRoles_ShouldSucceed()
        {
            string[] userRoles = new string[] { "role1", "role2" };
            MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(_dirMapperSvc);

            builder.BypassUserRoles(userRoles);

            IEnumerable <BypassUserRoleOption> options = builder.GetOptions()
                                                         .GetAll <BypassUserRoleOption>();

            options
            .ShouldNotBeNull()
            .Count()
            .ShouldBe(userRoles.Count());
            userRoles
            .ShouldContain(options.First().Value);
        }