Implement a C# console application following the TDD approach to replace all occurrences of a substring (S1) in a given string (S) with another substring (S2).
Example:
Input: S = "abababa", S1 = "aba", S2 = "a"
Output: "aba"
Explanation: "abababa" is modified by replacing "aba" at positions [0,2] and [4,6] with "a", resulting in "aba".
Conditions & Rules:
S can have a maximum length of 50 characters.
No spaces allowed in any of the strings; ignore spaces if present.
Only alphanumeric characters are allowed; special characters are not permitted.
None of the strings (S, S1, S2) should be null or empty; handle such cases gracefully.
S1 (substring to be replaced) cannot be longer than S.