Jump to content
CCleaner Community Forums
SMalik

Improvements in interface and functionality

Recommended Posts

2.

However it would be multiple files and folders.

I realize allot of shell extensions, or even drag 'n' drop secure delete programs can have issues working correctly 100% of the time as in sometimes a file is shredded correctly but the shredded file is left on the disk and not deleted from view.

Share this post


Link to post
Share on other sites

what is the issue? if you want it to apply to all files, you have to add a hive to HKEY CLASSES ROOT/* which is basic enough.

EX:

HKEY_CLASSES_ROOT\123\shell\********
HKEY_CLASSES_ROOT\123\shell\********\command
@=C:\Program Files\********folder\********.EXE %1

This was an unfinished test mock(15 years ago or just under i think) i used that allowed a user to download CCleaner, install & uninstall context menus and upload multiple files to image shack.

 



Imports DX
Imports Rhino.Mocks
Imports Rhino.Mocks.Constraints
Imports Xunit
Imports Xunit.Extensions

' Tests the ShellContextMenuProcess class.
Public Class TestShellContextMenuProcess

    <Fact()> _
    Public Sub SetProcessManager_ProcessManagerIsNull_Throws()
        Dim expectedExceptionType As Type = GetType(ArgumentNullException)

        Dim exceptionWasThrown As Boolean
        Try
            Dim sut As New ShellContextMenuProcess()
            sut.SetProcessManager(Nothing)
        Catch ex As Exception
            exceptionWasThrown = True
            Assert.IsType(expectedExceptionType, ex)
        End Try

        Assert.True(exceptionWasThrown, "Exception was not thrown.")
    End Sub
    <Fact()> _
    Public Sub StartInstall_Invariant_UsesRegisterArgument()
        Dim sut As New ShellContextMenuProcess()
        Dim expectedMode As String = "register"
        Dim processManagerMock As ProcessManager = New ProcessManagerMockThatExpectsModeArgument(expectedMode)
        sut.SetProcessManager(processManagerMock)

        sut.Install()

        CType(processManagerMock, ProcessManagerMockThatExpectsModeArgument).Verify()
    End Sub

    <Fact()> _
    Public Sub StartUninstall_Invariant_UsesUnregisterArgument()
        Dim sut As New ShellContextMenuProcess()
        Dim expectedMode As String = "unregister"
        Dim processManagerMock As ProcessManager = New ProcessManagerMockThatExpectsModeArgument(expectedMode)
        sut.SetProcessManager(processManagerMock)

        sut.Uninstall()

        CType(processManagerMock, ProcessManagerMockThatExpectsModeArgument).Verify()
    End Sub

    <Fact()> _
    Public Sub WaitForExit_Success_ReturnsTrue()
        Dim expectedValue As Boolean = True
        Dim sut As New ShellContextMenuProcess()
        Dim processManagerStub As ProcessManager = New ProcessManagerStubThatReturnsSpecificExitCode(ShellContextMenuProcess.SuccessCode)
        sut.SetProcessManager(processManagerStub)

        Dim actualValue As Boolean = sut.Install()

        Assert.Equal(expectedValue, actualValue)
    End Sub

    <Fact()> _
    Public Sub WaitForExit_Failure_ReturnsFalse()
        Dim expectedValue As Boolean = False
        Dim sut As New ShellContextMenuProcess()
        Dim processManagerStub As ProcessManager = New ProcessManagerStubThatReturnsSpecificExitCode(ShellContextMenuProcess.FailureCode)
        sut.SetProcessManager(processManagerStub)

        Dim actualValue As Boolean = sut.Install()

        Assert.Equal(expectedValue, actualValue)
    End Sub


    ' Handwritten mock that tests that the Arguments property is set and it has the expected mode.
    Private Class ProcessManagerMockThatExpectsModeArgument
        Inherits ProcessManager

        Private Const ExpectedNumberOfArguments As Integer = 2
        Private _expectedMode As String
        Private _propertyWasSet As Boolean

        Public Sub New(ByVal expectedMode As String)
            MyBase.New("asdf")
            _expectedMode = expectedMode
            _propertyWasSet = False
        End Sub

        Public Overrides Property Arguments() As String()
            Get
                Return MyBase.Arguments
            End Get
            Set(ByVal value As String())
                Assert.Equal(ExpectedNumberOfArguments, value.Length)
                Assert.Equal(_expectedMode, value(1))
                MyBase.Arguments = value
                _propertyWasSet = True
            End Set
        End Property

        Public Sub Verify()
            Assert.True(_propertyWasSet, "Arguments was not set.")
        End Sub

        ' Always returns success
        Protected Overrides Function GetExitCodeCore() As Integer
            Return ShellContextMenuProcess.SuccessCode
        End Function

        Protected Overrides Sub StartProcess()
            ' Do nothing, we don't need to start a process for tests.
        End Sub

        Protected Overrides Sub WaitForExitCore()
            ' Do nothing.
        End Sub
    End Class

    ' ProcessManager stub that returns a desired exit code and has no other logic.
    Public Class ProcessManagerStubThatReturnsSpecificExitCode
        Inherits ProcessManager

        Private _exitCode As Integer

        Public Sub New(ByVal exitCode As Integer)
            MyBase.New("asdf")
            _exitCode = exitCode
        End Sub

        Protected Overrides Function GetExitCodeCore() As Integer
            Return _exitCode
        End Function

        Protected Overrides Sub StartProcess()
            ' Do nothing.
        End Sub

        Protected Overrides Sub WaitForExitCore()
            ' Do nothing
        End Sub
    End Class
End Class


Imports DX
Imports Xunit
Imports Xunit.Extensions
Imports Rhino.Mocks

' Tests the ShellContextMenuInstaller class.
Public Class TestShellContextMenuInstaller

    <Fact()> _
    Public Sub Install_Failure_ReturnsFalse()
        Dim expectedValue As Boolean = False
        Dim sut As New ShellContextMenuInstaller()
        Dim processStub As ShellContextMenuProcess = New ShellContextMenuProcessStub_ReturnsSpecificValue_FromGetWaitForExit(expectedValue)
        sut.SetProcess(processStub)

        Dim actualValue As Boolean = sut.Install()
        Assert.Equal(expectedValue, actualValue)
    End Sub

    <Fact()> _
    Public Sub Install_Success_ReturnsTrue()
        Dim expectedValue As Boolean = True
        Dim sut As New ShellContextMenuInstaller()
        Dim processStub As ShellContextMenuProcess = New ShellContextMenuProcessStub_ReturnsSpecificValue_FromGetWaitForExit(expectedValue)
        sut.SetProcess(processStub)

        Dim actualValue As Boolean = sut.Install()
        Assert.Equal(expectedValue, actualValue)
    End Sub

    <Fact()> _
    Public Sub Uninstall_Failure_ReturnsFalse()
        Dim expectedValue As Boolean = False
        Dim sut As New ShellContextMenuInstaller()
        Dim processStub As ShellContextMenuProcess = New ShellContextMenuProcessStub_ReturnsSpecificValue_FromGetWaitForExit(expectedValue)
        sut.SetProcess(processStub)

        Dim actualValue As Boolean = sut.Uninstall()
        Assert.Equal(expectedValue, actualValue)
    End Sub

    <Fact()> _
    Public Sub Uninstall_Success_ReturnsTrue()
        Dim expectedValue As Boolean = True
        Dim sut As New ShellContextMenuInstaller()
        Dim processStub As ShellContextMenuProcess = New ShellContextMenuProcessStub_ReturnsSpecificValue_FromGetWaitForExit(expectedValue)
        sut.SetProcess(processStub)

        Dim actualValue As Boolean = sut.Uninstall()
        Assert.Equal(expectedValue, actualValue)
    End Sub

    Private Class ShellContextMenuProcessStub_ReturnsSpecificValue_FromGetWaitForExit
        Inherits ShellContextMenuProcess

        Private _expectedValue As Boolean

        Public Sub New(ByVal expectedValue As Boolean)
            MyBase.New()
            _expectedValue = expectedValue
            Dim mocks As New MockRepository()
            SetProcessManager(mocks.Stub(Of ProcessManager)("asdf"))
        End Sub

        Public Overrides Function GetTargetPath() As String
            Return ""
        End Function

        Protected Overrides Function WaitForExit() As Boolean
            Return _expectedValue
        End Function
    End Class
End Class

Passing a List(of Q off to a task factory, for instance, is nothing to you guys. Whats the issue? I understand each new file would be sent to a new instance, so this leaves us with a couple options I know
which ain't pretty like me

1) SEND TO PATH: Nasty ain't it. No commands would be needed but.....yes let's move on from that one.

2) could CC work with MultiSelectModel verb..... Too tired to look into this but it's how video plays work. I think.


3) let me write the class for you in VB.Net http://www.vbforums.com/member.php?113656-ident

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×