Beispiel #1
0
        public void Log_WhenNotExists_CreateFile()
        {
            //Arrange
            _mockWrapper
            .Setup_FileExists(false)
            .Setup_CreateFile();
            _mockLogic
            .Setup_GetLogPathName("log.txt");
            FileLogger logger = new FileLogger(_mockWrapper.Object, _mockLogic.Object);

            //Act
            logger.Log("Test");

            //Assert
            _mockWrapper.Verify_FileExits(Times.Once);
            _mockWrapper.Verify_CreateFile(Times.Once);
        }
Beispiel #2
0
        public void GetLogPathName_WhenWeekendDay_CheckAndSaveFormerWeekendFile()
        {
            //Arrange
            DateTime saturdayTest = new DateTime(2020, 6, 6);

            _mockWrapper
            .Setup_FileExists(true)
            .Setup_GetLastWriteTime(saturdayTest.AddDays(-6))
            .Setup_MoveFile();

            //Act
            string fileName = new FileLogic(_mockWrapper.Object).GetLogPathName(saturdayTest);

            //Assert
            Assert.Equal("weekend.txt", fileName);
            _mockWrapper.Verify_GetLastWriteTime(Times.Once);
            _mockWrapper.Verify_MoveFile(Times.Once);
            _mockWrapper.Verify_MoveFile_withNewFileName("weekend-20200530.txt", Times.Once);
        }