public void CanPerformOperation_GIVEN_Ctor_user_Has_Operation_But_Identity_Is_Not_Authenticated_THEN_Returns_False() { const string OperationName = "ABC"; var operation = new Operation { Name = OperationName }; var role = new Role { Name = "role" }; role.AddOperation(operation); var user = new User(); user.SetProperty(u => u.Id, 1); user.AddRole(role); var mockedIdentity = new Mock<IJumbleblocksIdentity>(); mockedIdentity.Setup(i => i.IsAuthenticated).Returns(false); var principal = new JumbleblocksPrincipal(mockedIdentity.Object, user); var result = principal.CanPerformOperation(OperationName); result.ShouldBeFalse(); }
public void CanPerformOperation_GIVEN_Ctor_user_Is_Null_THEN_Returns_False() { var mockedIdentity = new Mock<IJumbleblocksIdentity>(); mockedIdentity.Setup(i => i.IsAuthenticated).Returns(true); var principal = new JumbleblocksPrincipal(mockedIdentity.Object, null); var result = principal.CanPerformOperation("ABC"); result.ShouldBeFalse(); }