public void Init() { _mockFileInfo = Substitute.For <IFileInfoWrapper>(); _mockFileInfo.Name.Returns("fileInfoName"); _mockFileInfo.FullName.Returns("fullFileName"); _mockFileInfo.CreationTime.Returns(new DateTime(2020, 12, 31)); _mockFileInfo.Extension.Returns(".txt"); _mockConsole = Substitute.For <IConsoleWrapper>(); _mockFile = Substitute.For <IFileWrapper>(); _mockFile.ReadAllText(_mockFileInfo.Name).Returns("5545"); _mockDirectory = Substitute.For <IDirectoryWrapper>(); _mockDirectory.CreateDirectory(_mockFileInfo.Name); _mockDirectory.GetCreationTime(_mockFileInfo.CreationTime.ToString(CultureInfo.InvariantCulture)); _target = new TxtHandler(_mockFile, _mockFileInfo, _mockConsole, _mockDirectory); }
public void CreateTest() { _target.Create(_mockFileInfo.Name); _mockDirectory.Received().CreateDirectory(_mockFileInfo.Name); _mockDirectory.Received().GetCreationTime(_mockFileInfo.CreationTime.ToString(CultureInfo.InvariantCulture)); _mockConsole.Received().WriteLine($"The directory was created successfully at {_mockDirectory.GetCreationTime("")}."); }
public override void Create(string path) { _directory.CreateDirectory(path); _console.WriteLine($"The directory was created successfully at {_directory.GetCreationTime(path)}."); }