コード例 #1
0
        public void WriteToFile_WriteTextToFile_FileContainsGivenText()
        {
            //Arrange
            var fileNamePrefix    = "testFile";
            var fileExtension     = "txt";
            var textToWriteToFile = "Text for test writing to file.";
            var strTimestamp      = System.DateTime.Now.ToString("yyyyMMdd_HHmmss");
            var fileName          = fileNamePrefix + "_" + strTimestamp + "." + fileExtension;

            //Act
            FileLibrary.WriteToFile(textToWriteToFile, fileNamePrefix, fileExtension);

            //Assert
            Assert.AreEqual(textToWriteToFile, File.ReadAllText(fileName));
            File.Delete(fileName);
        }
コード例 #2
0
        public void WriteToFile_WriteTextToFile_FileIsCrated()
        {
            //Arrange
            var fileNamePrefix    = "testFile";
            var fileExtension     = "txt";
            var textToWriteToFile = "Text for test writing to file.";
            var strTimestamp      = System.DateTime.Now.ToString("yyyyMMdd_HHmmss");
            var fileName          = fileNamePrefix + "_" + strTimestamp + "." + fileExtension;

            //Act
            FileLibrary.WriteToFile(textToWriteToFile, fileNamePrefix, fileExtension);

            //Assert
            Assert.IsTrue(File.Exists(fileName));
            File.Delete(fileName);
        }