Esempio n. 1
0
        public void ToDomain_ShouldThrowExceptionGivenInputHasEmptyRows(string invalidContent)
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { InputFilePath, new MockFileData(invalidContent) }
            });
            var reader = new TextFileInputReader(fileSystem, _wallMapper.Object, _spiderMapper.Object);

            Action act = () => reader.Read(InputFilePath);

            act.Should().Throw <InputException>();
        }
Esempio n. 2
0
        public void ToDomain_ShouldThrowExceptionGivenInputDoesNotHaveEnoughRows(int invalidNumberOfRows)
        {
            var inputLines = _fixture.CreateMany <string>(invalidNumberOfRows);
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { InputFilePath, new MockFileData(string.Join('\r', inputLines)) }
            });
            var reader = new TextFileInputReader(fileSystem, _wallMapper.Object, _spiderMapper.Object);

            Action act = () => reader.Read(InputFilePath);

            act.Should().Throw <InputException>();
        }
Esempio n. 3
0
        public void Read_ShouldReturnBuildingObjectGivenValidInputData()
        {
            var expectedBuilding = _fixture.Create <Building>();
            var inputLines       = _fixture.CreateMany <string>();
            var fileSystem       = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { InputFilePath, new MockFileData(string.Join('\r', inputLines)) }
            });

            _wallMapper.Setup(x => x.ToDomain(It.IsAny <string>())).Returns(expectedBuilding.Wall);
            _spiderMapper.Setup(x => x.ToDomains(It.IsAny <IEnumerable <string> >())).Returns(expectedBuilding.Spiders);
            var reader = new TextFileInputReader(fileSystem, _wallMapper.Object, _spiderMapper.Object);

            var result = reader.Read(InputFilePath);

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(expectedBuilding);
        }