public void Should_calculate_programmer_rank_shown_in_example_1() { var programmerA = new Programmer("A", null); var programmerB = new Programmer("B", null); programmerA.Recommends(programmerB); programmerB.Recommends(programmerA); var rankedProgrammers = new Programmers(new List <IProgrammer> { programmerA, programmerB }); rankedProgrammers.Calculate(); Assert.That(programmerA.Rank, Is.EqualTo(1m).Within(0.00001m)); Assert.That(programmerB.Rank, Is.EqualTo(1m).Within(0.00001m)); }
public void Should_calculate_programmer_rank_shown_in_example_2() { var programmerA = new Programmer("A", null); var programmerB = new Programmer("B", null); var programmerC = new Programmer("C", null); var programmerD = new Programmer("D", null); programmerA.Recommends(programmerB); programmerA.Recommends(programmerC); programmerB.Recommends(programmerC); programmerC.Recommends(programmerA); programmerD.Recommends(programmerC); var rankedProgrammers = new Programmers(new List <IProgrammer> { programmerA, programmerB, programmerC, programmerD }); rankedProgrammers.Calculate(); Assert.That(programmerA.Rank, Is.EqualTo(1.49010m).Within(0.00001m)); Assert.That(programmerB.Rank, Is.EqualTo(0.78329m).Within(0.00001m)); Assert.That(programmerC.Rank, Is.EqualTo(1.57659m).Within(0.00001m)); Assert.That(programmerD.Rank, Is.EqualTo(0.15m).Within(0.00001m)); }