Ejemplo n.º 1
0
        public void CreatePlants_WillFailIfPositionAlreadyTaken()
        {
            var given = new List <Event>
            {
                new CreateBoardAccepted(20, 20, new List <Herbivore>(), new List <Carnivore>(), Message.CausationId,
                                        Message.CorrelationId, Message.CreatedOn),
                new CreatePlantAccepted("plantId", 2, 3, Message)
            };

            var when = new CreatePlants(2, 3, "plantId", Message.Id);

            Execute(given, when, typeof(Surface.PositionAlreadyTakenException), events => new Surface(events, new Random()));
        }
Ejemplo n.º 2
0
        public void CreatePlants_HaveRightLocation()
        {
            var given = new List <Event>
            {
                new CreateBoardAccepted(20, 20, new List <Herbivore>(), new List <Carnivore>(), Message.CausationId,
                                        Message.CorrelationId, Message.CreatedOn)
            };

            var when = new CreatePlants(2, 3, "test_plant", Message.Id);
            var then = new List <Event>
            {
                new CreatePlantAccepted("test_plant", 2, 3, Message)
            };

            var results = Execute(given, when, then, events => new Surface(events, new Random()));

            var carnivores = results.Select(r => (CreatePlantAccepted)r).ToList();

            foreach (var carnivore in carnivores)
            {
                Assert.Single(carnivores, c => c.X == carnivore.X && c.Y == carnivore.Y);
            }
        }