public void DebugItem_SaveFile_With_Contents_Expected_SavesFileToDisk() { var debugState = new DebugItem(); debugState.ClearFile("TestDebugItemFile.txt"); EnvironmentVariables.WebServerUri = "http://localhost:3142"; var uri = debugState.SaveFile(LongText, "TestDebugItemFile.txt"); var path = new Uri(uri).OriginalString.Replace("?DebugItemFilePath=", "").Replace(EnvironmentVariables.WebServerUri + "/Services/FetchDebugItemFileService", ""); var exists = File.Exists(path); Assert.IsTrue(exists); var contents = File.ReadAllText(path); Assert.AreEqual(LongText, contents); }
public void DebugIem_SaveFile_WithContentsNewLineChars_ExpectedSavesFileToDiskWithCorrectChars() { var debugState = new DebugItem(); debugState.ClearFile("TestSpecialCharsFile.txt"); EnvironmentVariables.WebServerUri = "http://localhost:3142"; const string expeced = "\r\nThis is\r\n the text\\n that we are writing"; const string textToWrite = "\nThis is\r\n the text\\n that we are writing"; var uri = debugState.SaveFile(textToWrite, "TestSpecialCharsFile.txt"); var path = new Uri(uri).OriginalString.Replace("?DebugItemFilePath=", "").Replace(EnvironmentVariables.WebServerUri + "/Services/FetchDebugItemFileService", ""); var exists = File.Exists(path); Assert.IsTrue(exists); var contents = File.ReadAllText(path); Assert.AreEqual(expeced, contents); }