Beispiel #1
0
        public async Task GetSqlOrderConfiguration_DirectoryAndFileConfigured_ReturnsAllfiles()
        {
            var command = new Command()
            {
                Path = ""
            };
            var fileReader = Substitute.For <IFileReader>();

            fileReader.FileExistsCheck(Arg.Any <string>()).Returns(true);
            var lines = new List <string>()
            {
                "path",
                "file 3"
            };
            var files = new List <string>()
            {
                "file 1",
                "file 2"
            };

            fileReader.GetLinesAsync(Arg.Any <string>()).Returns(lines);
            fileReader.DirectoryExistsCheck($"{command.Path}/path").Returns(true);
            fileReader.GetFiles($"{command.Path}/path").Returns(files);
            var confReader = new WithRepoConfigurationReader(fileReader, command);

            var result = await confReader.GetSqlOrderConfiguration();

            Assert.AreEqual(new List <string>()
            {
                "file 1",
                "file 2",
                "file 3"
            }, result.FileOrder);
        }
Beispiel #2
0
        public async Task GetSqlOrderConfiguration_FileNotExists_ReturnsEmptyList()
        {
            var fileReader = Substitute.For <IFileReader>();
            var command    = Substitute.For <Command>();

            fileReader.FileExistsCheck(Arg.Any <string>()).Returns(false);
            var confReader = new WithRepoConfigurationReader(fileReader, command);

            var result = await confReader.GetSqlOrderConfiguration();

            Assert.AreEqual(0, result.FileOrder.Count());
        }
Beispiel #3
0
        public async Task GetSqlOrderConfiguration_ReadConfiguration_ReturnsSame()
        {
            var fileReader = Substitute.For <IFileReader>();
            var command    = Substitute.For <Command>();

            fileReader.FileExistsCheck(Arg.Any <string>()).Returns(true);
            var lines = new List <string>()
            {
                "line 1",
                "line 2"
            };

            fileReader.GetLinesAsync(Arg.Any <string>()).Returns(lines);
            var confReader = new WithRepoConfigurationReader(fileReader, command);

            var result = await confReader.GetSqlOrderConfiguration();

            Assert.AreEqual(lines, result.FileOrder);
        }