public void File_Version_Argument_Outputs_File_Version() { var fileVersionArguments = new string[] { "file", "version" }; var result = new FileInformationArguments() { FileName = "the file.name", Operation = OperationParameters.Version, }; var expectedVersion = "v1.2.3"; var argumentParser = _mockFactory.Create <IArgumentParser>(); argumentParser.Setup(ap => ap.Parse(It.Is <string[]>(s => s == fileVersionArguments))).Returns(new MethodResult <FileInformationArguments>(result)); var fileInformation = _mockFactory.Create <IFileInformationProvider>(); fileInformation.Setup(fi => fi.GetVersion(It.Is <string>(s => s == result.FileName))).Returns(expectedVersion); var outputWrapper = _mockFactory.Create <IOutputWrapper>(); outputWrapper.Setup(o => o.OutputString(It.Is <string>(s => s == expectedVersion))); outputWrapper.Setup(o => o.Wait()); var target = new FileProcessor(argumentParser.Object, fileInformation.Object, outputWrapper.Object); target.GetInformation(fileVersionArguments); argumentParser.VerifyAll(); outputWrapper.VerifyAll(); fileInformation.VerifyAll(); }
public void Unknown_Operation_Throws_Exception() { var newOperationArguments = new string[] { "undefined" }; var unknownOperation = new FileInformationArguments() { Operation = (OperationParameters)Enum.GetValues(typeof(OperationParameters)).Cast <int>().Min() - 1, FileName = "file.name", }; var argumentParser = _mockFactory.Create <IArgumentParser>(); argumentParser.Setup(ap => ap.Parse(It.Is <string[]>(s => s == newOperationArguments))).Returns(new MethodResult <FileInformationArguments>(unknownOperation)); var target = new FileProcessor(argumentParser.Object, null, null); try { target.GetInformation(newOperationArguments); Assert.Fail(); } catch { } argumentParser.VerifyAll(); }