namespace InterviewExercise
public static string ReverseSentenceWords(string sentence)
var words = sentence.Split(' ');
for (var i = words.Length - 1; i >= 0; i--) {
result += words[i] + " ";
return result.Substring(0, sentence.Length);
public static void Main()
var x = new NUnitLite.AutoRun().Execute(new string[]{"--test:InterviewExercise.ReverserTests", "--noc"});
Console.WriteLine("----------------------------------------------");
Console.WriteLine(x==0?"All Test Passed... :¬)": string.Format("{0} tests failed... :¬(", x));
Console.WriteLine("----------------------------------------------");
public class ReverserTests
[TestCase("Hello", "Hello", Description = "Hello")]
[TestCase("Hello world", "world Hello", Description = "Hello world")]
[TestCase("Hello and happy new year!", "year! new happy and Hello", Description = "Hello and happy new year!")]
[TestCase("", "", Description = "Empty string")]
[TestCase(" ", " ", Description = "Whitespace")]
public void Reverse_ShouldReverseSentence(string input, string expected)
var revertedSentence = Reverser.ReverseSentenceWords(input);
Assert.AreEqual(expected, revertedSentence);