Ejemplo n.º 1
0
 /// <summary>
 /// Sets the content of the provided file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="content">The content.</param>
 /// <returns>The same <see cref="FakeFile"/> instance so that multiple calls can be chained.</returns>
 public static FakeFile SetContent(this FakeFile file, string content)
 {
     using (var stream = file.Open(FileMode.Create, FileAccess.Write, FileShare.None))
         using (var writer = new StreamWriter(stream))
         {
             writer.Write(content);
             writer.Close();
             stream.Close();
             return(file);
         }
 }
Ejemplo n.º 2
0
 public static FakeFile SetContent(this FakeFile file, string content)
 {
     if (file == null)
     {
         throw new ArgumentNullException(nameof(file));
     }
     if (content == null)
     {
         throw new ArgumentNullException(nameof(content));
     }
     using (var stream = file.Open(FileMode.Create, FileAccess.Write, FileShare.None))
         using (var writer = new StreamWriter(stream))
         {
             writer.Write(content);
             file.LastWriteTime = DateTime.Now;
             return(file);
         }
 }
Ejemplo n.º 3
0
 public static FakeFile SetContent(this FakeFile file, string content)
 {
     if (file == null)
     {
         throw new ArgumentNullException("file");
     }
     if (content == null)
     {
         throw new ArgumentNullException("content");
     }
     using (var stream = file.Open(FileMode.Create, FileAccess.Write, FileShare.None))
         using (var writer = new StreamWriter(stream))
         {
             writer.Write(content);
             writer.Close();
             stream.Close();
             return(file);
         }
 }