Exemplo n.º 1
0
 public void SetUp()
 {
     _persons = new List<Person>();
     _calculation = new Calculation(_persons);
     _first = new Person { Spent = 10.0 };
     _second = new Person { Spent = 20.0 };
 }
Exemplo n.º 2
0
        public IList<Details> GetDetails(Person person)
        {
            var gives = Persons.Count(p => p.Debt > 0);
            var gets = Persons.Count(p => p.Debt < 0);

            var details = Persons.Where(p => p.Debt != 0.0)
                .Where(p => p != person)
                .OrderBy(p => p.Debt)
                .Select(p => (new Details { Name = p.Name, Get = p.Debt / gives, Give = p.Debt / gets}))
                .ToList();
            return details;
        }
Exemplo n.º 3
0
        public void GetDetailsTest()
        {
            _first.Spent = 16.0;
            _persons.Add(_first);
            _persons.Add(_second);
            var third = new Person { Spent = 6.0 };
            _persons.Add(third);
            _calculation.Process();
            var details = _calculation.GetDetails(third);

            Assert.AreEqual(2, details.Count);
            Assert.AreEqual(2.0, details[0].Give);
            Assert.AreEqual(6.0, details[1].Give);
        }
Exemplo n.º 4
0
 public ParticipantViewModel(Person model)
 {
     Model = model;
 }