public override bool IsValid(params ILegalPerson[] persons) { if (Consent != null && Consent.IsValid(persons)) { AddReasonEntry($"{nameof(Consent)} {nameof(IsValid)} is true"); AddReasonEntryRange(Consent.GetReasonEntries()); return(true); } var subjectPerson = GetSubjectOfSearch(persons); if (subjectPerson == null) { AddReasonEntry($"{nameof(GetSubjectOfSearch)} returned nothing"); return(false); } var title = subjectPerson.GetLegalPersonTypeName(); if (!IsPrivacyExpected(subjectPerson)) { AddReasonEntry($"{title} {subjectPerson.Name}, {nameof(IsPrivacyExpected)} is false"); return(false); } if (!IsPrivacyExpectedReasonable(subjectPerson)) { AddReasonEntry($"{title} {subjectPerson.Name}, {nameof(IsPrivacyExpectedReasonable)} is false"); return(false); } return(true); }
/// <summary> /// Tests that <see cref="Consent"/> was not given by <see cref="SubjectProperty"/> owner /// </summary> /// <param name="persons"></param> /// <returns></returns> protected virtual bool WithoutConsent(ILegalPerson[] persons) { //is all the dependencies present if (SubjectProperty?.IsEntitledTo == null || Consent == null || persons == null || !persons.Any()) { return(true); } //if all the people are licensed or invited then consent is implied by the use of type (label) if (persons.Where(v => !SubjectProperty.IsEntitledTo(v)).All(p => p is ILicensee)) { AddReasonEntry($"all non-owner persons implement {nameof(ILicensee)} interface type"); return(false); } //did the caller pass in any IVictim types var victims = persons.Victims().ToList(); if (!victims.Any()) { return(true); } //is any of our victims also the owner of the property var ownerVictims = victims.Where(v => SubjectProperty.IsEntitledTo(v)).ToList(); if (!ownerVictims.Any()) { AddReasonEntry($"of {nameof(IVictim)}s named " + $"{string.Join(",", victims.Select(v => v.Name))}, " + $"none are found {nameof(SubjectProperty.IsEntitledTo)} as true"); return(true); } foreach (var ownerVictim in ownerVictims) { var validConsent = Consent.IsValid(ownerVictim); AddReasonEntryRange(Consent.GetReasonEntries()); //did the owner victim in fact give consent if (validConsent != ConsentExpectedAs) { AddReasonEntry($"owner-{ownerVictim.GetLegalPersonTypeName()} {ownerVictim.Name}, " + $"{nameof(Consent)} {nameof(IsValid)} " + $"is {validConsent}, it was expected to be {ConsentExpectedAs} " + $"for property {SubjectProperty.Name}"); return(false); } } return(true); }
public override bool IsValid(params ILegalPerson[] persons) { if (Consent != null && Consent.IsValid(persons)) { AddReasonEntryRange(Consent?.GetReasonEntries()); return(true); } var suspect = this.Suspect(persons, GetSuspect); if (suspect == null) { return(false); } var suspectTitle = suspect.GetLegalPersonTypeName(); if (!IsInCoercivePressureEnvironment(suspect)) { AddReasonEntry($"{suspectTitle} {suspect.Name}, {nameof(IsInCoercivePressureEnvironment)} is false"); return(false); } if (!IsIncriminatoryQuestioning(suspect)) { AddReasonEntry($"{suspectTitle} {suspect.Name}, {nameof(IsIncriminatoryQuestioning)} is false"); return(false); } if (IsPublicSafetyException(suspect)) { AddReasonEntry($"{suspectTitle} {suspect.Name}, {nameof(IsPublicSafetyException)} is false"); return(false); } if (!IsToldRightToAttorney(suspect)) { AddReasonEntry($"{suspectTitle} {suspect.Name}, {nameof(IsToldRightToAttorney)} is false"); return(false); } if (!IsToldRightToRemainSilent(suspect)) { AddReasonEntry($"{suspectTitle} {suspect.Name}, {nameof(IsToldRightToRemainSilent)} is false"); return(false); } return(true); }
public override bool IsValid(params ILegalPerson[] persons) { if (Consent != null && Consent.IsValid(persons)) { AddReasonEntry($"{nameof(Consent)} {nameof(IsValid)} is true"); AddReasonEntryRange(Consent.GetReasonEntries()); return(true); } if (!IsValidBeforePredicates(persons)) { return(false); } var suspect = GetSubjectOfSearch(persons); var suspectTitle = suspect.GetLegalPersonTypeName(); var officer = GetConductorOfSearch(persons); var officerTitle = officer.GetLegalPersonTypeName(); //allow implementor to assert these from either perspective var gantItem1 = (IsArresteeUnsecured(suspect) || IsArresteeUnsecured(officer)) && (IsArresteeNearPassengerCompartment(suspect) || IsArresteeNearPassengerCompartment(officer)); if (gantItem1) { return(true); } var gantItem2 = IsBeliefEvidenceToCrimeIsPresent(suspect) || IsBeliefEvidenceToCrimeIsPresent(officer); if (gantItem2) { return(true); } AddReasonEntry($"{officerTitle} {officer.Name} arrest of {suspectTitle} {suspect.Name}, " + $"{nameof(IsArresteeUnsecured)} and {nameof(IsArresteeNearPassengerCompartment)} " + "are both false"); AddReasonEntry($"{officerTitle} {officer.Name} arrest of {suspectTitle} {suspect.Name}, " + $"{nameof(IsBeliefEvidenceToCrimeIsPresent)} is false"); return(false); }
public override bool IsValid(params ILegalPerson[] persons) { var defendant = this.Defendant(persons); if (defendant == null) { return(false); } var title = defendant.GetLegalPersonTypeName(); //is consented to jurisdiction if (Consent != null && Consent.IsValid(persons)) { AddReasonEntryRange(Consent.GetReasonEntries()); if (!GetReasonEntries().Any()) { AddReasonEntry($"{title} {defendant.Name}, {nameof(Consent)} {nameof(IsValid)} returned true"); } return(true); } //is pass minimum contact test if (IsMinimumContact(persons)) { return(true); } //idea of general in personam jurisdiction if (IsCourtDomicileLocationOfDefendant(defendant, title)) { return(true); } if (IsCourtCurrentLocationOfDefendant(defendant, title)) { return(true); } return(false); }
public override bool IsValid(params ILegalPerson[] persons) { if (Consent != null && Consent.IsValid(persons)) { AddReasonEntry($"{nameof(Consent)} {nameof(IsValid)} is true"); AddReasonEntryRange(Consent.GetReasonEntries()); return(true); } if (GetConductorOfSearch == null) { GetConductorOfSearch = lps => null; } var officer = GetConductorOfSearch(persons); if (officer == null) { AddReasonEntry($"{nameof(GetConductorOfSearch)} returned nothing"); return(false); } var officerTitle = officer.GetLegalPersonTypeName(); if (!IsBeliefEvidenceToCrimeIsPresent(officer)) { AddReasonEntry($"{officerTitle} {officer.Name}, {nameof(IsBeliefEvidenceToCrimeIsPresent)} is false"); return(false); } if (!IsLimitToAreaToPossibleHidden(officer)) { AddReasonEntry($"{officerTitle} {officer.Name}, {nameof(IsLimitToAreaToPossibleHidden)} is false"); return(false); } return(true); }