//[InlineData(-1, null, null, null)] public void PersonOfferorMark_ShouldThrow(int mark, Person sender, PersonOfferor receiver, DateTime dateOccur) { PersonOfferorMark pom = new PersonOfferorMark(); pom.DateOccur = dateOccur; pom.Mark = mark; pom.Sender = sender; pom.Receiver = receiver; Assert.ThrowsAny <Exception>(() => pom.ValidateObject()); }
public void PersonOfferorMark_ShouldInstantiatePersonOfferorMark() { PersonOfferorMark pom = new PersonOfferorMark(); pom.DateOccur = new DateTime(); pom.IdOfferorMark = 1; pom.Mark = 5; pom.Sender = new Person(); pom.Receiver = new PersonOfferor(); pom.ValidateObject(); Assert.NotNull(pom); }
/// <summary> /// Posts the mark. /// </summary> /// <param name="fromPerson">From person.</param> /// <param name="toPerson">To person.</param> /// <param name="mark">The mark.</param> /// <exception cref="System.Exception">A PERSON IS NOT REGISTERED!</exception> public void PostMark(Person fromPerson, Person toPerson, int mark) { IPersonOfferorTable personOfferorTable = this.tablesProvider.GetPersonOfferorTable(); IPersonMarkTable personMarkTable = this.tablesProvider.GetPersonMarkTable(); fromPerson.ValidateObject(); toPerson.ValidateObject(); if (fromPerson.IdPerson == 0 || toPerson.IdPerson == 0) { throw new Exception("A PERSON IS NOT REGISTERED!"); } PersonOfferor offeror = personOfferorTable.FetchPersonOfferorByPerson(toPerson); if (mark > MaxMarkRating || mark < MinMarkRating) { throw new Exception("BadRating"); } PersonOfferorMark markObj = new PersonOfferorMark() { DateOccur = DateTime.Now, Mark = mark, Receiver = offeror, Sender = fromPerson }; personMarkTable.InsertPersonMark(markObj); Log.Info("mark registered!"); PersonOfferorService offerorService = new PersonOfferorService(offeror); List <PersonOfferorMark> marks = personMarkTable.FetchPersonOfferorMarks(offeror); offerorService.UpdateRatingBasedOnMarks(marks); if (offerorService.Rating < minRatingAllowedForBidding) { offeror.LastBannedDate = DateTime.Now; offerorService.UpdateIsBanned(); personOfferorTable.UpdatePersonOfferor(offeror); } }
public void InsertPersonMark(PersonOfferorMark personMark) { personMark.IdOfferorMark = index++; list.Add(personMark); }