示例#1
0
        public static async Task ValidateFalse()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization {
                ConfigureMembers = true
            });

            fixture.Customize <Response.Permission>(ctx => ctx
                                                    .With(x => x.PermissionId, 1)
                                                    .With(x => x.PermissionBit, 1234));

            var mock   = fixture.Create <IFor>();     // Act
            var target = new ManagePermissions(mock);
            var result = await target
                         .Permissions(1234)
                         .Allow(4)
                         .ValidateAsync();

            // Assert
            result.ShouldBe(false);
        }
示例#2
0
        public static async Task PermissionsIgnoreOther()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization {
                ConfigureMembers = true
            });

            fixture.Customize <Response.Permission>(ctx => ctx
                                                    .With(x => x.PermissionBit, 1));

            var mock = fixture.Create <IFor>();

            // Act
            var target = new ManagePermissions(mock);
            await target.Permissions(1234).SetToAsync(4);

            // Assert
            await mock
            .Received(0)
            .UpdateAsync(Arg.Any <Response.ApplicationGroup>(), Arg.Any <Response.PermissionsSetId>(), Arg.Any <Response.Permission>());
        }
示例#3
0
        public static async Task ValidateOtherPermission()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization {
                ConfigureMembers = true
            });

            fixture.Customize <Response.ApplicationGroup>(ctx => ctx
                                                          .With(x => x.FriendlyDisplayName, "some-name"));

            fixture.Customize <Response.Permission>(ctx => ctx
                                                    .With(x => x.PermissionId, 1)
                                                    .With(x => x.PermissionBit, 1234));

            var mock   = fixture.Create <IFor>();     // Act
            var target = new ManagePermissions(mock);
            var result = await target
                         .Permissions(4444)
                         .Allow(4)
                         .ValidateAsync();

            // Assert
            result.ShouldBe(true);
        }