public void MappingToMembership_DeclineWaitedEnough()
        {
            var membership = new MembershipStateEntity
            {
                AddMember   = true,
                MessageDate = DateTimeOffset.Now.AddMonths(-1)
            };

            var tuple = _repository.MappingToMembership(membership);

            Assert.False(tuple.Item1);
            Assert.True(tuple.Item2 == "");
        }
        public void MappingToMembership_AlreadyMember()
        {
            var membership = new MembershipStateEntity
            {
                AddMember   = true,
                MessageDate = DateTimeOffset.Now
            };

            var tuple = _repository.MappingToMembership(membership);

            Assert.False(tuple.Item1);
            Assert.True(tuple.Item2 == "");
        }
        public void MappingToMembership_RequestPending()
        {
            var membership = new MembershipStateEntity
            {
                AddMember   = null,
                MessageDate = DateTimeOffset.Now
            };

            var tuple = _repository.MappingToMembership(membership);

            Assert.False(tuple.Item1);
            Assert.True(tuple.Item2 == "Your request is pending");
        }
        public void MappingToMembership_DeclineMustWait()
        {
            var membership = new MembershipStateEntity
            {
                AddMember   = false,
                MessageDate = DateTimeOffset.Now.AddDays(-10)
            };

            var tuple = _repository.MappingToMembership(membership);

            Assert.False(tuple.Item1);
            Assert.True(tuple.Item2 == "Your unable to send a join request until " +
                        membership.MessageDate.Value.AddMonths(1).ToString("dd/MM/yyyy"));
        }
Ejemplo n.º 5
0
 public Tuple <bool, string> MappingToMembership(MembershipStateEntity membershipStateEntity)
 {
     if (membershipStateEntity is null)
     {
         return(new Tuple <bool, string>(true, ""));
     }
     if (membershipStateEntity.AddMember == true)
     {
         return(new Tuple <bool, string>(false, ""));
     }
     if (membershipStateEntity.AddMember is null)
     {
         return(new Tuple <bool, string>(false, "Your request is pending"));
     }
     if (membershipStateEntity.AddMember == false && membershipStateEntity.MessageDate.Value.AddMonths(1) <= DateTime.Now)
     {
         return(new Tuple <bool, string>(true, ""));
     }
     return(new Tuple <bool, string>(false, "Your unable to send a join request until " +
                                     membershipStateEntity.MessageDate.Value.AddMonths(1).ToString("dd/MM/yyyy")));
 }