public void AddFileName_throws_ArgumentNullException_when_fileName_empty() { using (var tempFileCollection = new TempFileCollection(Path.GetTempPath())) { Assert.Throws <ArgumentNullException>(() => tempFileCollection.AddFileName(null)); Assert.Throws <ArgumentNullException>(() => tempFileCollection.AddFileName(String.Empty)); } }
public void AddFileName_throws_ArgumentException_when_duplicate() { var fileName = "test"; using (var tempFileCollection = new TempFileCollection(Path.GetTempPath())) { tempFileCollection.AddFileName(fileName); Assert.Throws <ArgumentException>(() => tempFileCollection.AddFileName(fileName)); } }
public void Dispose_deletes_files() { var fileName = Path.GetTempFileName(); using (var tempFileCollection = new TempFileCollection(Path.GetTempPath())) using (File.Create(fileName)) { Assert.True(File.Exists(fileName)); tempFileCollection.AddFileName(fileName); } Assert.False(File.Exists(fileName)); }