public Philosopher(int id, Chopstick leftChopstick, Chopstick rightChopstick)
 {
     LeftChopstick = leftChopstick;
     RightChopstick = rightChopstick;
     _id = id;
 }
 public Philosopher(int id)
 {
     _id = id;
     LeftChopstick = new Chopstick();
     RightChopstick = new Chopstick();
 }
        public void Meal_ListPhilosophersAllEat_Returns()
        {
            var chopstick1 = new Chopstick(1);
            var chopstick2 = new Chopstick(2);
            var chopstick3 = new Chopstick(3);
            var chopstick4 = new Chopstick(4);
            var chopstick5 = new Chopstick(5);

            var philosophers = new List<Philosopher>
            {
                new Philosopher(1, chopstick1, chopstick2),
                new Philosopher(2, chopstick2, chopstick3),
                new Philosopher(3, chopstick3, chopstick4),
                new Philosopher(4, chopstick4, chopstick5),
                new Philosopher(5, chopstick5, chopstick1)
            };
            Parallel.ForEach(philosophers,new ParallelOptions { MaxDegreeOfParallelism = 5}, philosopher =>
            {
                philosopher.Consume();
            });
        }
 public void Setup()
 {
     _chopstick = new Chopstick(1);
     _philosopher = new Philosopher(1);
 }
        public void Eat_GivenTwoPhilosophersAndTwoChopSticksWhenPhilosopherOneEatsPhilosopher2Cannot_ReturnsFalse()
        {
            var chopstick1 = new Chopstick(1);
            var chopstick2 = new Chopstick(2);

            var philosopher1 = new Philosopher(1,chopstick1, chopstick2);
            var philosopher2 = new Philosopher(2, chopstick2, chopstick1);

            philosopher1.Eat();

            Assert.That(philosopher2.Eat(), Is.False);
        }