Beispiel #1
0
        public void ParseShipsCoordinates_CorrectData_ReturnResults(string text, int count)
        {
            CoordinatesParser parser = Create();

            IReadOnlyCollection <ShipDomainModel> results = parser.ParseShipsCoordinates(text);

            Assert.NotNull(results);
            Assert.Equal(count, results.Count);
        }
Beispiel #2
0
        public void ParseShipsCoordinates_CorrectData_ReturnCorrectResults(string text, int x1, int y1, int x2, int y2)
        {
            CoordinatesParser parser = Create();

            IReadOnlyCollection <ShipDomainModel> results = parser.ParseShipsCoordinates(text);

            Assert.NotNull(results);
            Assert.Single(results);

            ShipDomainModel p = results.First();

            Assert.Equal(Math.Min(x1, x2), p.Start.X);
            Assert.Equal(Math.Min(y1, y2), p.Start.Y);
            Assert.Equal(Math.Max(x1, x2), p.End.X);
            Assert.Equal(Math.Max(y1, y2), p.End.Y);
        }
Beispiel #3
0
        public void ParseShipsCoordinates_IncorrectData_ThrowException(string text)
        {
            CoordinatesParser parser = Create();

            Assert.Throws <DataValidationException>(() => parser.ParseShipsCoordinates(text));
        }