Example #1
0
        public void AddRightRoleIntoRelationship_FailTest()
        {
            var husbandType = new PartyRoleType("Husband");
            var husbandRole = new PartyRole(husbandType);

            var whifeType = new PartyRoleType("Whife");
            var whifeRole = new PartyRole(whifeType);

            var familyRelationshipTyp = new PartyRelationshipType("Family");
            var famalyCanHasHusband   = new PartyRelationshipConstraint(husbandType);

            familyRelationshipTyp.AddConstraint(famalyCanHasHusband);
            var famalyCanHasWhife = new PartyRelationshipConstraint(whifeType);

            familyRelationshipTyp.AddConstraint(famalyCanHasWhife);

            var familyRelationship = new PartyRelationship(familyRelationshipTyp);

            familyRelationship.AddRole(husbandRole);
            familyRelationship.AddRole(whifeRole);

            var john = new Person()
            {
                Birthdate = new DateTime(1972, 11, 4)
            };

            familyRelationship.Assign(husbandRole, john);
            var marry = new Person()
            {
                Birthdate = new DateTime(1976, 4, 16)
            };

            familyRelationship.Assign(whifeRole, marry);

            Assert.AreEqual(2, familyRelationship.Roles.Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(john).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(marry).Count());
        }
        public void AddCommunications_SuccessTest()
        {
            var customerRoleType         = new PartyRoleType("Customer");
            var customerRole             = new PartyRole(customerRoleType);
            var customerRelationshipType = new PartyRelationshipType("Customers relationship");
            var customerRelationship     = new PartyRelationship(customerRelationshipType);

            customerRelationship.AddRole(customerRole);

            var vlad = new Person();

            customerRelationship.Assign(customerRole, vlad);
            var ilona = new Person();

            customerRelationship.Assign(customerRole, ilona);

            var customerServiceRepresentativeRoleType = new PartyRoleType("CustomerServiceRepresentative");
            var customerServiceRepresentativeRole     = new PartyRole(customerServiceRepresentativeRoleType);
            var communicationRelationshipType         = new PartyRelationshipType("Communication relationship");
            var communicationRelationship             = new Communication(communicationRelationshipType);

            communicationRelationship.AddRole(customerServiceRepresentativeRole);

            communicationRelationship.Assign(customerServiceRepresentativeRole, vlad);
            communicationRelationship.Assign(customerServiceRepresentativeRole, ilona);

            var customerCommunicationManager = new CustomerCommunicationManager();
            var customerServiceCase          = new CustomerServiceCase(new CustomerServiceCaseIdentifier(Guid.NewGuid()));

            customerCommunicationManager.AddCustomerServiceCases(customerServiceCase);
            var thread1 = new CommunicationThread();

            customerServiceCase.AddThread(thread1);
            var communication = new Communication(communicationRelationshipType);

            thread1.AddCommunication(communicationRelationship);
        }
        /// <summary>
        /// Returns true if CustomerUpdate instances are equal
        /// </summary>
        /// <param name="other">Instance of CustomerUpdate to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CustomerUpdate other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     StatusReason == other.StatusReason ||
                     StatusReason != null &&
                     StatusReason.Equals(other.StatusReason)
                 ) &&
                 (
                     ValidFor == other.ValidFor ||
                     ValidFor != null &&
                     ValidFor.Equals(other.ValidFor)
                 ) &&
                 (
                     EngagedParty == other.EngagedParty ||
                     EngagedParty != null &&
                     EngagedParty.Equals(other.EngagedParty)
                 ) &&
                 (
                     PartyRoleType == other.PartyRoleType ||
                     PartyRoleType != null &&
                     PartyRoleType.Equals(other.PartyRoleType)
                 ) &&
                 (
                     Account == other.Account ||
                     Account != null &&
                     Account.SequenceEqual(other.Account)
                 ) &&
                 (
                     Characteristic == other.Characteristic ||
                     Characteristic != null &&
                     Characteristic.SequenceEqual(other.Characteristic)
                 ) &&
                 (
                     CreditProfile == other.CreditProfile ||
                     CreditProfile != null &&
                     CreditProfile.SequenceEqual(other.CreditProfile)
                 ) &&
                 (
                     Agreement == other.Agreement ||
                     Agreement != null &&
                     Agreement.SequenceEqual(other.Agreement)
                 ) &&
                 (
                     RelatedParty == other.RelatedParty ||
                     RelatedParty != null &&
                     RelatedParty.SequenceEqual(other.RelatedParty)
                 ));
        }
Example #4
0
        public void ValidateEntityValueConstraine_SuccessTest()
        {
            var husbandType = new PartyRoleType("Husband");
            var husbendMustBeOlderThen18 = new RuleSet(new Func <object, bool>((x) =>
            {
                var person = x as Person;
                if (person.Age > 18)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }));

            husbandType.AddRule(husbendMustBeOlderThen18);
            var husbandRole = new PartyRole(husbandType);

            var whifeType = new PartyRoleType("Whife");
            var whifeMustBeOlderThen16 = new RuleSet(new Func <object, bool>((x) =>
            {
                var person = x as Person;
                if (person.Age > 16)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }));

            whifeType.AddRule(whifeMustBeOlderThen16);
            var whifeRole = new PartyRole(whifeType);

            var childrenType = new PartyRoleType("Children");
            var childrenMustBeYangerThenParents = new RuleSet(new Func <object, bool>((x) =>
            {
                return(true);
            }));

            childrenType.AddRule(childrenMustBeYangerThenParents);
            var childrenRole = new PartyRole(childrenType);

            var familyRelationshipTyp = new PartyRelationshipType("Family");
            var famalyCanHasHusband   = new PartyRelationshipConstraint(husbandType);

            familyRelationshipTyp.AddConstraint(famalyCanHasHusband);
            var famalyCanHasWhife = new PartyRelationshipConstraint(whifeType);

            familyRelationshipTyp.AddConstraint(famalyCanHasWhife);
            var famalyCanHasChildren = new PartyRelationshipConstraint(childrenType);

            familyRelationshipTyp.AddConstraint(famalyCanHasChildren);

            var familyRelationship = new PartyRelationship(familyRelationshipTyp);

            familyRelationship.AddRole(husbandRole);
            familyRelationship.AddRole(whifeRole);
            familyRelationship.AddRole(childrenRole);

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, husbandRole.Type.Rules.Count());

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, whifeRole.Type.Rules.Count());

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, childrenRole.Type.Rules.Count());

            var john = new Person()
            {
                Birthdate = new DateTime(1972, 11, 4)
            };

            familyRelationship.Assign(husbandRole, john);
            var marry = new Person()
            {
                Birthdate = new DateTime(1976, 4, 16)
            };

            familyRelationship.Assign(whifeRole, marry);
            var gimmy = new Person()
            {
                Birthdate = new DateTime(1996, 4, 16)
            };

            familyRelationship.Assign(childrenRole, gimmy);

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(john).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(marry).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(gimmy).Count());
        }
Example #5
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         if (StatusReason != null)
         {
             hashCode = hashCode * 59 + StatusReason.GetHashCode();
         }
         if (ValidFor != null)
         {
             hashCode = hashCode * 59 + ValidFor.GetHashCode();
         }
         if (EngagedParty != null)
         {
             hashCode = hashCode * 59 + EngagedParty.GetHashCode();
         }
         if (PartyRoleType != null)
         {
             hashCode = hashCode * 59 + PartyRoleType.GetHashCode();
         }
         if (Account != null)
         {
             hashCode = hashCode * 59 + Account.GetHashCode();
         }
         if (PaymentMethod != null)
         {
             hashCode = hashCode * 59 + PaymentMethod.GetHashCode();
         }
         if (ContactMedium != null)
         {
             hashCode = hashCode * 59 + ContactMedium.GetHashCode();
         }
         if (Characteristic != null)
         {
             hashCode = hashCode * 59 + Characteristic.GetHashCode();
         }
         if (CreditProfile != null)
         {
             hashCode = hashCode * 59 + CreditProfile.GetHashCode();
         }
         if (Agreement != null)
         {
             hashCode = hashCode * 59 + Agreement.GetHashCode();
         }
         if (RelatedParty != null)
         {
             hashCode = hashCode * 59 + RelatedParty.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #6
0
        /// <summary>
        /// Returns true if Customer instances are equal
        /// </summary>
        /// <param name="other">Instance of Customer to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Customer other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Href == other.Href ||
                     Href != null &&
                     Href.Equals(other.Href)
                     ) &&
                 (
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     StatusReason == other.StatusReason ||
                     StatusReason != null &&
                     StatusReason.Equals(other.StatusReason)
                 ) &&
                 (
                     PreferredLanguage == other.PreferredLanguage ||
                     PreferredLanguage != null &&
                     PreferredLanguage.Equals(other.PreferredLanguage)
                 ) &&
                 (
                     ValidFor == other.ValidFor ||
                     ValidFor != null &&
                     ValidFor.Equals(other.ValidFor)
                 ) &&
                 (
                     EngagedParty == other.EngagedParty ||
                     EngagedParty != null &&
                     EngagedParty.Equals(other.EngagedParty)
                 ) &&
                 (
                     PartyRoleType == other.PartyRoleType ||
                     PartyRoleType != null &&
                     PartyRoleType.Equals(other.PartyRoleType)
                 ) &&
                 (
                     Account == other.Account ||
                     Account != null &&
                     Account.SequenceEqual(other.Account)
                 ) &&
                 (
                     PaymentMethod == other.PaymentMethod ||
                     PaymentMethod != null &&
                     PaymentMethod.SequenceEqual(other.PaymentMethod)
                 ) &&
                 (
                     ContactMedium == other.ContactMedium ||
                     ContactMedium != null &&
                     ContactMedium.SequenceEqual(other.ContactMedium)
                 ) &&
                 (
                     Characteristic == other.Characteristic ||
                     Characteristic != null &&
                     Characteristic.SequenceEqual(other.Characteristic)
                 ) &&
                 (
                     CreditProfile == other.CreditProfile ||
                     CreditProfile != null &&
                     CreditProfile.SequenceEqual(other.CreditProfile)
                 ) &&
                 (
                     Agreement == other.Agreement ||
                     Agreement != null &&
                     Agreement.SequenceEqual(other.Agreement)
                 ) &&
                 (
                     RelatedParty == other.RelatedParty ||
                     RelatedParty != null &&
                     RelatedParty.SequenceEqual(other.RelatedParty)
                 ));
        }