public void WithoutCall() { var source = GenerateStorage; var singleAverageGetter = new SingleAverageGetter(new AverageKeeperFactory(), new SelectorByCountryAndAge()); var selectorByCountryAndAgeMock = new SelectorByCountryAndAgeMock(); var grossSalaryAverageSetter = new GrossSalaryAverageSetter(selectorByCountryAndAgeMock); var checkStorage = GenerateStorage; Assert.Equal(0, selectorByCountryAndAgeMock.CountOfCalling); Func <Person, string> serializer = p => $"{p.Age} {p.Country} {p.Gender} {p.GrossSalary}"; Assert.True(checkStorage.Select(serializer).SequenceEqual(source.Select(serializer))); }
public void CommonCase() { var source = GenerateStorage; var singleAverageGetter = new SingleAverageGetter(new AverageKeeperFactory(), new SelectorByCountryAndAge()); var age = 20; var country = "USA"; var average = 4000; var selectorByCountryAndAgeMock = new SelectorByCountryAndAgeMock(); var grossSalaryAverageSetter = new GrossSalaryAverageSetter(selectorByCountryAndAgeMock); var result = grossSalaryAverageSetter.SetAverage(source, age, country, average); Assert.Equal(average, singleAverageGetter.Calculate(result.ToList(), age, country)); Assert.Equal(1, selectorByCountryAndAgeMock.CountOfCalling); Assert.True(result.SequenceEqual(selectorByCountryAndAgeMock.CopyOfLastReturnedCollection)); }
public void EmptyCase() { var source = GenerateStorage; var age = 25; var country = "USA"; var average = 4000; var selectorByCountryAndAgeMock = new SelectorByCountryAndAgeMock(); var grossSalaryAverageSetter = new GrossSalaryAverageSetter(selectorByCountryAndAgeMock); var result = grossSalaryAverageSetter.SetAverage(source, age, country, average); var checkStorage = GenerateStorage; Assert.Equal(1, selectorByCountryAndAgeMock.CountOfCalling); Assert.False(result.Any()); Func <Person, string> serializer = p => $"{p.Age} {p.Country} {p.Gender} {p.GrossSalary}"; Assert.True(checkStorage.Select(serializer).SequenceEqual(source.Select(serializer))); }