public void AddOperation_GIVEN_Operation_Already_Added_WHEN_Added_Again_THEN_Does_Not_Add_To_List_Again() { var operation = new Operation { Name = "Operation" }; var role = new Role { Name = "Role" }; role.AddOperation(operation); role.AddOperation(operation); role.Operations.ShouldContain(operation); role.Operations.Count().ShouldEqual(1); }
public void AddOperation_Add_Operation_To_List() { var operation = new Operation { Name = "Operation" }; var role = new Role { Name = "Role" }; role.AddOperation(operation); role.Operations.ShouldContain(operation); }
public void HasOperation_GIVEN_User_Has_Operation_With_Name_DEF_WHEN_operationName_Is_ABC_THEN_Returns_False() { var operation = new Operation { Name = "DEF" }; var role = new Role { Name = "Role" }; role.AddOperation(operation); var result = role.HasOperation("ABC"); result.ShouldBeFalse(); }
public void HasOperation_GIVEN_User_Has_Operation_With_Name_ABC_WHEN_operationName_Is_ABC_THEN_Returns_True() { const string OperationName = "ABC"; var operation = new Operation { Name = OperationName }; var role = new Role { Name = "Role" }; role.AddOperation(operation); var result = role.HasOperation(OperationName); result.ShouldBeTrue(); }
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 HasOperation_GIVEN_Has_Operation_ABC_WHEN_operationName_IS_DEF_THEN_Returns_False() { const string OperationName = "ABC"; const string CheckOperationName = "DEF"; var role = new Role { Name = "role" }; role.AddOperation(new Operation { Name = OperationName }); var user = new User(); user.SetProperty(u => u.Id, 1); user.AddRole(role); var principal = new JumbleblocksPrincipal(new JumbleblocksUserIdentity(user), user); var result = principal.HasOperation(CheckOperationName); result.ShouldBeFalse(); }
public void AddOperation_WHEN_operation_Is_Null_THEN_Throws_ArgumentNullException() { var role = new Role { Name = "Role" }; role.AddOperation(null); }