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); }
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); }
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); } }
public MooreCellLifeService(ILifePreset lifePreset) { lifePreset.ThrowIfNull(nameof(lifePreset)); LifePreset = lifePreset; }