public void InsertsNewAuthorNewRatingWhenDeleteManyOldVictims() { var organization = "organization"; var repository = "repository"; var author = new FakeAuthor(organization, repository, "new author"); var victim1 = new FakeAuthor(organization, repository, "old first victim"); var victim2 = new FakeAuthor(organization, repository, "old second victim"); var work1 = new FakeWork(3, victim1); var work2 = new FakeWork(4, victim2); var newWork = new FakeWork(0u, author); var ratings = new List <Rating> { new FakeRating(50, work1, victim1), new FakeRating(40, work2, victim2) }; var formula = new FakeFormula(10, 1); var deletion1 = new DefaultDeletion(victim1.Email(), 2); var deletion2 = new DefaultDeletion(victim2.Email(), 3); new DefaultEntityFactory( new FakeEntities( new List <Work> { work1, work2, newWork }, new List <Author>(), ratings ), formula ) .InsertRatings( organization, repository, author.Email(), new[] { deletion1, deletion2 }, newWork.Id(), DateTimeOffset.UtcNow ); bool RatingOfAuthor(Rating r) { return(r.Author().Email().Equals(author !.Email())); } Assert.Equal( formula.WinnerNewRating( formula.DefaultRating(), new[] { new DefaultMatch(formula.DefaultRating(), deletion1.Counted()), new DefaultMatch(formula.DefaultRating(), deletion2.Counted()) } ), ratings.Single(RatingOfAuthor).Value() ); }
public void InsertsNewAuthorNewRatingWhenDeleteOneOldVictim() { var organization = "organization"; var repository = "repository"; var author = new FakeAuthor(organization, repository, "new author"); var victim = new FakeAuthor(organization, repository, "old single victim"); var work = new FakeWork(3, victim); var newWork = new FakeWork(0u, author); var ratings = new List <Rating> { new FakeRating(50, work, victim) }; var formula = new FakeFormula(10, 1); var deletion = new DefaultDeletion(victim.Email(), 2); new DefaultEntityFactory( new FakeEntities( new List <Work> { work, newWork }, new List <Author> { victim }, ratings ), formula ) .InsertRatings(organization, repository, author.Email(), new[] { deletion }, newWork.Id(), DateTimeOffset.UtcNow); bool RatingOfAuthor(Rating r) { return(r.Author().Email().Equals(author !.Email())); } Assert.Equal( formula.WinnerNewRating( formula.DefaultRating(), new[] { new DefaultMatch(formula.DefaultRating(), deletion.Counted()) } ), ratings.Single(RatingOfAuthor).Value() ); }
public void InsertsNewVictimNewRating() { var ratings = new List <Rating>(); var organization = "organization"; var repository = "repository"; var author = new FakeAuthor(organization, repository, "author"); var formula = new FakeFormula(10, 1); var victim = "single victim"; var deletion = new DefaultDeletion(victim, 2); var newWork = new FakeWork(0u, author); new DefaultEntityFactory( new FakeEntities( new List <Work> { newWork }, new List <Author>(), ratings ), formula ) .InsertRatings(organization, repository, author.Email(), new[] { deletion }, newWork.Id(), DateTimeOffset.UtcNow); bool RatingOfVictim(Rating r) { return(r.Author().Email().Equals(victim)); } Assert.Equal( formula.LoserNewRating( formula.DefaultRating(), new DefaultMatch(formula.DefaultRating(), deletion.Counted()) ), ratings.Single(RatingOfVictim).Value() ); }