public void GeneratePattern_ExpectedDimensions(int seed, int width, int height, int numMarkers)
        {
            var random  = new Random(seed);
            var service = new InterferenceService();

            var pattern = service.Generate(random, width, height, numMarkers);

            Assert.NotNull(pattern);

            var display = pattern.ToString();

            Assert.NotNull(display);

            var displayLines = display.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.Equal(height * 4 + 2, displayLines.Length);
            Assert.Equal(string.Empty, displayLines.Last());

            foreach (var line in displayLines.Take(displayLines.Length - 1))
            {
                Assert.Equal(width * 4 + 1, line.Length);
            }

            Assert.Equal(numMarkers, pattern.MarkerSequence.Count);
            Assert.Equal(numMarkers, pattern.SolutionSequence.Count);
            Assert.Equal(numMarkers, pattern.Arrows.Count);
        }
예제 #2
0
        public void GeneratePattern(int seed, string expectedSequence, string expectedLayout)
        {
            var random  = new Random(seed);
            var service = new InterferenceService();

            var pattern = service.Generate(random, 4, 8, 6);

            Assert.NotNull(pattern);

            var display = pattern.ToString();

            Assert.NotNull(display);
            Assert.Equal(expectedLayout.Trim(), display.Trim());

            string actualSequence = string.Join(string.Empty, pattern.SolutionSequence);

            Assert.Equal(expectedSequence, actualSequence);
        }