Ejemplo n.º 1
0
        public void AddOccupant_Works()
        {
            Bay bay = new TestBay(null, 20);

            bay.AddOccupant(new Citizen {
                Name = "TestWorker"
            });

            Assert.IsTrue(bay.Occupants[0].Name == "TestWorker", "Could not find the worker that we just added");
        }
Ejemplo n.º 2
0
        public void RemoveOccupant_Works()
        {
            Bay     bay  = new TestBay(null, 10);
            Citizen work = new Citizen {
                Name = "TestWorker"
            };

            bay.AddOccupant(work);
            bay.RemoveOccupant(work);
            Assert.IsFalse(bay.Occupants.Contains(work), "Citizen was not removed");
        }
Ejemplo n.º 3
0
        public void AddOccupant_CollectionWorks()
        {
            Bay            bay  = new TestBay(null, 10);
            List <Citizen> work = new List <Citizen>( );

            Repeat(8, i => work.Add(new Citizen {
                Name = $"Worker_{i}"
            }));
            bay.AddOccupantRange(work);
            Repeat(8, i => Assert.IsTrue(bay.Occupants[i].Name == $"Worker_{i}", $"Missing worker {i}"));
        }
Ejemplo n.º 4
0
        public void AddOccupant_RunsFailureInsteadOfException()
        {
            Bay bay = new TestBay(null, 10);

            Repeat(10, i => bay.AddOccupant(new Citizen {
                Name = $"Worker_{i}"
            }));
            bool works = false;

            bay.AddOccupant(new Citizen {
            }, () => works = true);
            Assert.IsTrue(works);
        }
Ejemplo n.º 5
0
        public void AddOccupant_RespectsLimit()
        {
            Bay bay = new TestBay(null, 2);

            bay.AddOccupant(new Citizen {
                Name = "TestWorker1"
            });
            bay.AddOccupant(new Citizen {
                Name = "TestWorker2"
            });
            bool works = false;

            bay.AddOccupant(new Citizen {
            }, () => works = true);
            Assert.IsTrue(works, "Did not respect limit");
        }