public void GivenFileExtensionAstxt() { //Given: path as 'd:\parking.txt' string path = @"d:\parking.txt"; //When: I call ValidateFileType object bool result = _validateFileType.IsValid(path); //Then: I get true Assert.IsTrue(result); }
public string Execute(string path) { StringBuilder messages = new StringBuilder(); try { bool isValid = _validateFileType.IsValid(path); if (isValid) { IEnumerable <string> commands = _fileReader.ReadFile(path); if (commands != null) { foreach (string command in commands) { ICommandExecutor executpr = _provider.InitExecutor(command); string message = executpr.ExecuteCommand(command); messages.AppendLine(message); } } else { messages.Append("Invalid file path"); } } else { messages.Append("Invalid file type"); } return(messages.ToString()); } catch (Exception ex) { throw; } }