예제 #1
0
        public void WhenExecuteCommandWithDirectoryPath_CommandManager_ShouldExecuteMoveDirectoryContent()
        {
            var mySourcePath      = "mypath";
            var myDestinationPath = "mypath";
            var storedDataService = new StoredDataServiceMock();

            var fileServiceMock = new FileServiceMock()
            {
                ExistsPathReturn = true, IsDirectoryReturn = true
            };
            var commandDefinition = new MovePathCommand(fileServiceMock);
            var instance          = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandSourcePathParameter.GetInvokeName(),
                mySourcePath,
                commandDefinition.CommandDestinationFolderParameter.GetInvokeName(),
                myDestinationPath);

            instance.ExecuteInputRequest(inputRequest);

            var expectedSourcePath       = mySourcePath;
            var expectedDestionationPath = myDestinationPath;
            var actualSourcePath         = fileServiceMock.MovedSourceFolder;
            var actualDestinationPath    = fileServiceMock.MovedDestionationFolder;

            Assert.Equal(expectedSourcePath, actualSourcePath);
            Assert.Equal(expectedDestionationPath, actualDestinationPath);
        }
예제 #2
0
        public void WhenExecuteCommandWithoutNonExistingSourcePath_CommandManager_ShouldThrowException()
        {
            var mySourcePath      = "mypath";
            var myDestinationPath = "mypath";
            var storedDataService = new StoredDataServiceMock();

            var fileServiceMock = new FileServiceMock()
            {
                ExistsPathReturn = false
            };
            var commandDefinition = new MovePathCommand(fileServiceMock);
            var instance          = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandSourcePathParameter.GetInvokeName(),
                mySourcePath,
                commandDefinition.CommandDestinationFolderParameter.GetInvokeName(),
                myDestinationPath);

            Assert.Throws <PathNotFoundException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest);
            });
        }