예제 #1
0
        public void Run_HasFileLength_LengthIsWrittenToConsole()
        {
            var fileEntry = new FileEntry
            {
                FullName = "SomeFile.txt",
                Length   = 123456789
            };

            string expectedLengthString = SizeFormatter.GetSizeString(fileEntry.Length);

            // Setup

            var settingsRepoMock = new Mock <ISettingsRepository>();

            Dependency.RegisterInstance(settingsRepoMock.Object);

            var consoleAdapterMock = new Mock <IConsoleAdapter>();

            Dependency.RegisterInstance(consoleAdapterMock.Object);

            // Test

            var displayController = new DisplayController();

            displayController.Display(new RunSettings(), fileEntry.AsArray());

            // Assert

            consoleAdapterMock.Verify(ca => ca.Write(expectedLengthString), Times.Once());
        }
예제 #2
0
        public void Run_ContainsDirectory_DisplaysDirectoryCorrectly()
        {
            var fileEntry = new FileEntry
            {
                FullName    = "ThisDirectory",
                IsDirectory = true
            };

            string actualString = string.Empty;

            // Setup

            var settingsRepoMock = new Mock <ISettingsRepository>();

            Dependency.RegisterInstance(settingsRepoMock.Object);

            var consoleAdapterMock = new Mock <IConsoleAdapter>();

            consoleAdapterMock.Setup(ca => ca.Write(It.IsAny <object>(), ConsoleColor.Magenta)).Callback <object, ConsoleColor>((s, c) => actualString = s.ToString());
            Dependency.RegisterInstance(consoleAdapterMock.Object);

            // Test

            var displayController = new DisplayController();

            displayController.Display(new RunSettings(), fileEntry.AsArray());

            // Assert

            Assert.IsTrue(actualString.StartsWith("Folder"));
        }