public void It_Should_Throw_A_RequirementInvalidException_Given_An_Invalid_Requirement()
        {
            void CreateInvalidRequirement()
            {
                var invalidRequirement = new ActiveNeighbourRequirement(new HashSet <int> {
                    -1, 10
                });
            }

            Assert.Throws(Is.TypeOf <RequirementInvalidException>(), CreateInvalidRequirement);
        }
Пример #2
0
        public static Rule GetOvercrowdingRule()
        {
            var cellAliveRequirement = new InitialStateRequirement(new HashSet <CellState> {
                CellState.Alive
            });
            var moreThanThreeNeighboursRequirement = new ActiveNeighbourRequirement(new HashSet <int> {
                4, 5, 6, 7, 8
            });
            var requirements = new List <IRequirement> {
                cellAliveRequirement, moreThanThreeNeighboursRequirement
            };

            return(new Rule(requirements, CellState.Dead));
        }
Пример #3
0
        public void Setup()
        {
            var overcrowdingRule = RuleCreator.GetOvercrowdingRule();

            var cellAliveRequirement = new InitialStateRequirement(new HashSet <CellState> {
                CellState.Alive
            });
            var eightNeighboursRequirement = new ActiveNeighbourRequirement(new HashSet <int> {
                8
            });

            var superOvercrowdingRequirements = new List <IRequirement> {
                cellAliveRequirement, eightNeighboursRequirement
            };
            var superOvercrowdingRule = new Rule(superOvercrowdingRequirements, CellState.Alive);

            var rules = new Dictionary <int, Rule>
            {
                { 1, superOvercrowdingRule },
                { 2, overcrowdingRule }
            };

            _ruleSet = new RuleSet(rules);
        }
 public void Setup()
 {
     _fourOrMoreActiveNeighboursRequirement = new ActiveNeighbourRequirement(new HashSet <int> {
         4, 5, 6, 7, 8
     });
 }