public void TestHandleSessionEventThatIsNotHandled() { MockFileSystemStateActions mock = new MockFileSystemStateActions(); Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>(); SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, mock, New <AxCryptFile>(), mockStatusChecker.Object); Assert.DoesNotThrowAsync(async() => { await handler.HandleNotificationAsync(new SessionNotification((SessionNotificationType)(-1))); }); mockStatusChecker.Verify(msc => msc.CheckStatusAndShowMessage(It.Is <ErrorStatus>(es => es == ErrorStatus.Exception), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public async Task TestHandleSessionEventPurgeActiveFiles() { MockFileSystemStateActions mock = new MockFileSystemStateActions(); bool called = false; mock.PurgeActiveFilesMock = (IProgressContext progress) => { return(Task.FromResult(called = true)); }; Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>(); SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, mock, New <AxCryptFile>(), mockStatusChecker.Object); await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.EncryptPendingFiles)); Assert.That(called, Is.True); }
public void TestHandleSessionEventThatCauseNoSpecificAction() { MockFileSystemStateActions mock = new MockFileSystemStateActions(); Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>(); SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, mock, New <AxCryptFile>(), mockStatusChecker.Object); Assert.DoesNotThrowAsync(async() => { await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.ProcessExit)); await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.SessionChange)); await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.KnownKeyChange)); await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.WorkFolderChange)); }); }