public void Paired_Numeric_Sequence_Has_No_Start_Item() { var sequenceGenerator = new PairedNumericSequenceGenerator(); var actual = sequenceGenerator.Generate(10); actual.FirstItem.Should().Be(null); }
public Grid GetPairedNumericGrid(int rows = 5, int columns = 2) { var grid = new Grid(rows, columns); var sequenceGenerator = new PairedNumericSequenceGenerator(); grid.PopulateCells(sequenceGenerator); grid.RandomiseCells(); return(grid); }
public void Paired_Numeric_Sequence_Only_Returns_Pairs() { var sequenceGenerator = new PairedNumericSequenceGenerator(); var actual = sequenceGenerator.Generate(10); var groupedNumbers = actual.Items.GroupBy(g => g.Value).ToDictionary(d => d.Key, d => d.Count()); groupedNumbers.Max(d => d.Value).Should().Be(2); groupedNumbers.Min(d => d.Value).Should().Be(2); actual.FirstItem.Should().Be(null); }
public void Paired_Numeric_Sequence_Pairs_Point_To_Each_Other() { var sequenceGenerator = new PairedNumericSequenceGenerator(); var actual = sequenceGenerator.Generate(10); for (int i = 0; i < actual.Items.Count; i++) { var itemBeingChecked = actual.Items[i]; var itemPair = actual.Items.Single(item => item.Value == itemBeingChecked.Value && item != itemBeingChecked); itemPair.NextItem.Should().Be(i + 1); // Not 0 based } actual.FirstItem.Should().Be(null); }