public void ReadAnAdventurerLine_GetEntries_ReturnsAnAdventurerEntryWithPopulatedProperties()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                string expectedType        = "A";
                string expectedName        = "Anna";
                int    expectedWidth       = 4;
                int    expectedHeight      = 3;
                string expectedOrientation = "S";
                string expectedMovements   = "AGAADAA";
                AppendString(inputStream, $"{expectedType}-{expectedName}-{expectedWidth}-{expectedHeight}-{expectedOrientation}-{expectedMovements}");
                inputStream.Position = 0;

                MapFileReader reader           = new MapFileReader();
                var           result           = reader.GetEntries(inputStream);
                var           firstEntryResult = result.FirstOrDefault();

                Assert.That(firstEntryResult, Is.Not.Null);
                Assert.That(firstEntryResult, Is.TypeOf(typeof(MapAdventurerEntry)));
                Assert.That(((MapAdventurerEntry)firstEntryResult).Name, Is.EqualTo(expectedName));
                Assert.That(((MapAdventurerEntry)firstEntryResult).X, Is.EqualTo(expectedWidth));
                Assert.That(((MapAdventurerEntry)firstEntryResult).Y, Is.EqualTo(expectedHeight));
                Assert.That(((MapAdventurerEntry)firstEntryResult).Orientation, Is.EqualTo(expectedOrientation));
                Assert.That(((MapAdventurerEntry)firstEntryResult).Movements, Is.EqualTo(expectedMovements));
            }
        }
        public void ReadACommentLine_GetEntries_ReturnsAnEmptyCollection()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                AppendString(inputStream, "# Super comment !");
                inputStream.Position = 0;

                MapFileReader reader = new MapFileReader();
                var           result = reader.GetEntries(inputStream);

                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count, Is.EqualTo(0));
            }
        }
        public void ReadABadFormattedMapLine_GetEntries_ThrowsInvalidArgument()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                string expectedType   = "C";
                int    expectedWidth  = 4;
                int    expectedHeight = 3;
                AppendString(inputStream, $"{expectedType}-{expectedWidth}-{expectedHeight}-xx");
                inputStream.Position = 0;

                MapFileReader reader = new MapFileReader();

                Assert.That(() => reader.GetEntries(inputStream).ToList(), Throws.Exception.TypeOf <ArgumentException>());
            }
        }
        public void ReadAWellFormattedLine_GetEntries_ReturnsOneMapEntryWithRightType()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                string expectedType = "C";
                AppendString(inputStream, $"{expectedType}-2-3");
                inputStream.Position = 0;

                MapFileReader          fileReader = new MapFileReader();
                IEnumerable <MapEntry> result     = fileReader.GetEntries(inputStream).ToList();

                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.EqualTo(1));
                Assert.That(result.First().Type, Is.EqualTo(expectedType));
            }
        }
        public void Read3WellFormattedLine_GetEntries_Returns3MapEntry()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                int expectedEntriesCount = 3;
                AppendString(inputStream, "C-3-3");
                AppendString(inputStream, "M-1-1");
                AppendString(inputStream, "T-2-2-2");
                inputStream.Position = 0;

                MapFileReader reader = new MapFileReader();
                var           result = reader.GetEntries(inputStream);

                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.EqualTo(expectedEntriesCount));
            }
        }
        public void ReadABadFormattedAdventurerLine_GetEntries_ThrowsInvalidArgument()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                string expectedType        = "A";
                string expectedName        = "Anna";
                int    expectedWidth       = 4;
                int    expectedHeight      = 3;
                string expectedOrientation = "S";
                string expectedMovements   = "AGAADAA";
                AppendString(inputStream, $"{expectedType}-{expectedName}-{expectedWidth}-{expectedHeight}-{expectedOrientation}-{expectedMovements}-xx");
                inputStream.Position = 0;

                MapFileReader reader = new MapFileReader();

                Assert.That(() => reader.GetEntries(inputStream).ToList(), Throws.Exception.TypeOf <ArgumentException>());
            }
        }
        public void ReadAMapLine_GetEntries_ReturnsAMapEntryWithPopulatedProperties()
        {
            using (MemoryStream inputStream = new MemoryStream())
            {
                string expectedType   = "C";
                int    expectedWidth  = 4;
                int    expectedHeight = 3;
                AppendString(inputStream, $"{expectedType}-{expectedWidth}-{expectedHeight}");
                inputStream.Position = 0;

                MapFileReader reader           = new MapFileReader();
                var           result           = reader.GetEntries(inputStream);
                var           firstEntryResult = result.FirstOrDefault();

                Assert.That(firstEntryResult, Is.Not.Null);
                Assert.That(firstEntryResult, Is.TypeOf(typeof(MapSizeEntry)));
                Assert.That(((MapSizeEntry)firstEntryResult).Width, Is.EqualTo(expectedWidth));
                Assert.That(((MapSizeEntry)firstEntryResult).Height, Is.EqualTo(expectedHeight));
            }
        }