예제 #1
0
        public void LifePreset_ShouldThrow_ExceptionOnNullSurvive()
        {
            ILifePreset lifePreset = null;
            //var message = $"Exception of type 'System.ArgumentNullException' was thrown.{Environment.NewLine}Parameter name: {"surviveValues"}";
            var message   = $"Value cannot be null.{Environment.NewLine}Parameter name: {"surviveValues"}";
            var exception = Record.Exception(() => lifePreset = new LifePreset(_bornValues, null));

            lifePreset.Should().BeNull();
            exception.Should().NotBeNull();
            exception.Message.Should().Be(message);
        }
예제 #2
0
        public void CellLifeService_ShouldThrow_ExceptionOnNullLifePreset()
        {
            ICellLifeService lifeCellService = null;
            ILifePreset      lifePreset      = null;
            var message = $"Value cannot be null.{Environment.NewLine}Parameter name: {nameof(lifePreset)}";
            //var message = $"Exception of type 'System.ArgumentNullException' was thrown.{Environment.NewLine}Parameter name: {nameof(lifePreset)}";
            var exception = Record.Exception(() => lifeCellService = new MooreCellLifeService(lifePreset));

            lifeCellService.Should().BeNull();
            exception.Should().NotBeNull();
            exception.Message.Should().Be(message);
        }
예제 #3
0
        public void LifePreset_Should_IgnoreWrongSurviveCounts()
        {
            ILifePreset lifePreset = null;
            var         exception  = Record.Exception(() => lifePreset = new LifePreset(_bornValues, new[] { -1, -2, 2, 3, 4, 7, 9, 15 }));

            lifePreset.Should().NotBeNull();
            exception.Should().BeNull();

            for (var pos = -10; pos < 20; pos++)
            {
                var actualResult   = lifePreset.Survive(pos);
                var expectedResult = _surviveValues.Contains(pos) || pos == 7;

                actualResult.Should().Be(expectedResult);
            }
        }
예제 #4
0
 public MooreCellLifeService(ILifePreset lifePreset)
 {
     lifePreset.ThrowIfNull(nameof(lifePreset));
     LifePreset = lifePreset;
 }