Ejemplo n.º 1
0
        public void FieldGenerator_SetsConflictForCoordinatesClosestToTwoOrMoreSources(int x, int y)
        {
            var sources = new List <string>
            {
                "1, 1",
                "1, 6",
                "8, 3",
                "3, 4",
                "5, 5",
                "8, 9",
            }.Select(Source.Parse);
            var generator = new FieldGenerator(new BoardFactory(sources).CreateBoard());

            var fields = generator.CreateFields(sources);

            Assert.Equal(Vector.Conflict, fields[x][y]);
        }
Ejemplo n.º 2
0
        public void FieldGenerator_SetsCoordinateClosestToOneSource(string closestSource, int x, int y)
        {
            var sources = new List <string>
            {
                "1, 1",
                "1, 6",
                "8, 3",
                "3, 4",
                "5, 5",
                "8, 9",
            }.Select(Source.Parse);
            var generator = new FieldGenerator(new BoardFactory(sources).CreateBoard());

            var fields = generator.CreateFields(sources);

            var expectedSource = Source.Parse(closestSource);

            Assert.Equal(expectedSource, fields[x][y].Source);
        }
Ejemplo n.º 3
0
        public void FieldGenerator_MarksSourcesWithFieldInfinity(string source, bool expectedInfinity)
        {
            var sources = new List <string>
            {
                "1, 1",
                "1, 6",
                "8, 3",
                "3, 4",
                "5, 5",
                "8, 9",
            }.Select(Source.Parse);
            var generator = new FieldGenerator(new BoardFactory(sources).CreateBoard());

            var fields = generator.CreateFields(sources);

            var actualInfinity = fields.SelectMany(x => x.ToList()).First(x => Equals(x.Source, Source.Parse(source))).Source.Infinity;

            Assert.Equal(expectedInfinity, actualInfinity);
        }
Ejemplo n.º 4
0
        public void FieldGenerator_SetsCoordinateUnderTheSource(string source)
        {
            var sources = new List <string>
            {
                "1, 1",
                "1, 6",
                "8, 3",
                "3, 4",
                "5, 5",
                "8, 9",
            }.Select(Source.Parse);
            var generator = new FieldGenerator(new BoardFactory(sources).CreateBoard());

            var fields = generator.CreateFields(sources);

            var expectedSource = Source.Parse(source);

            Assert.Equal(expectedSource, fields[expectedSource.X][expectedSource.Y].Source);
            Assert.Equal(0, fields[expectedSource.X][expectedSource.Y].Distance);
        }
Ejemplo n.º 5
0
        public void DistanceCollator_CalculatesCorrectAddeUpDistance()
        {
            var sources = new List <string>
            {
                "1, 1",
                "1, 6",
                "8, 3",
                "3, 4",
                "5, 5",
                "8, 9",
            }.Select(Source.Parse);
            var generator = new FieldGenerator(new BoardFactory(sources).CreateBoard());
            var fields    = sources.Select(x => generator.CreateFields(new List <Source> {
                x
            }));
            var collator = new DistanceCollator();

            var distanceField = collator.AddUpDistances(fields);

            Assert.Equal(30, distanceField[4][3]);
        }
        public void FieldGenerator_CreateFields_ReturnsListOf37Fields()
        {
            var uut = new FieldGenerator();

            Assert.That(uut.CreateFields().Count, Is.EqualTo(37));
        }
        public void FieldGenerator_CreateFieldsFirstFieldIs0_ReturnsField0n()
        {
            var uut = new FieldGenerator();

            Assert.That(uut.CreateFields()[0].Number, Is.EqualTo(0));
        }
        public void FieldGenerator_CreateFieldsFirstFieldIsGreen_ReturnsFieldGreen()
        {
            var uut = new FieldGenerator();

            Assert.That(uut.CreateFields()[0].Color, Is.EqualTo(Field.Green));
        }