예제 #1
0
        public void AddLineToFile_LogLineIsNull_ThrowsNullReferenceException()
        {
            // Arrange
            var dh = new DocumentHelper(_testDirectory);

            dh.CreateDirectory();
            dh.CreateFile(DateTime.Now);
            LogLine logLine = null;

            // Act
            Action act = () => dh.AddLineToFile(logLine);

            // Assert
            act.ShouldThrow <NullReferenceException>();
        }
예제 #2
0
        public void AddLineToFile_LogLineIsSet_StringFormat()
        {
            //Arrange
            var dh = new DocumentHelper(_testDirectory);

            dh.CreateDirectory();
            dh.CreateFile(DateTime.Now);
            LogLine logLine = new LogLine();

            // Act
            Action act = () => dh.AddLineToFile(logLine);

            // Assert
            act.ShouldNotThrow();
        }
예제 #3
0
        public void DateCheckAndCreateFile_DayIsDifferent_NewfileIsCreated()
        {
            //Arrange
            var dh = new DocumentHelper(_testDirectory);

            dh.CreateDirectory();
            var curDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
            var logDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);

            dh.CreateFile(curDate);

            //Act
            dh.DateCheckAndCreateFile(curDate, logDate);

            //Assert
            Assert.IsTrue(File.Exists($@"{_testDirectory}\Log{logDate.ToString("yyyyMMdd HHmmss fff")}.log"));
        }
예제 #4
0
 public void CreateLogFile()
 {
     _dHelper.CreateDirectory();
     _dHelper.CreateFile(_curDate);
 }