text:
/*
 * Created on 31.01.2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.cs3.pdt.editor.internal.views.lightweightOutline;

import static org.cs3.prolog.connector.common.QueryUtils.bT;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.cs3.pdt.common.PDTCommonPlugin;
import org.cs3.pdt.common.PDTCommonUtil;
import org.cs3.pdt.common.PrologProcessStartListener;
import org.cs3.pdt.common.metadata.SourceLocation;
import org.cs3.pdt.connector.PDTConnectorPlugin;
import org.cs3.pdt.connector.service.ActivePrologProcessListener;
import org.cs3.pdt.connector.service.ConsultListener;
import org.cs3.pdt.connector.util.FileUtils;
import org.cs3.pdt.editor.PDT;
import org.cs3.pdt.editor.PDTPlugin;
import org.cs3.pdt.editor.PDTPredicates;
import org.cs3.pdt.editor.internal.ImageRepository;
import org.cs3.pdt.editor.internal.editors.PLEditor;
import org.cs3.pdt.editor.internal.queries.PDTOutlineQuery;
import org.cs3.pdt.editor.internal.structureElements.OutlineClauseElement;
import org.cs3.pdt.editor.internal.structureElements.OutlineFileElement;
import org.cs3.pdt.editor.internal.structureElements.OutlineModuleElement;
import org.cs3.pdt.editor.internal.structureElements.OutlinePredicateElement;
import org.cs3.prolog.connector.common.Debug;
import org.cs3.prolog.connector.common.QueryUtils;
import org.cs3.prolog.connector.process.PrologProcess;
import org.cs3.prolog.connector.process.PrologProcessException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;

public class NonNaturePrologOutline extends ContentOutlinePage implements ConsultListener, ActivePrologProcessListener, PrologProcessStartListener, IDoubleClickListener {
	private static final int EXPANDING_LEVEL = 2;
	public static final String MENU_ID = "org.cs3.pdt.editor.outline.menu";
	private ITreeContentProvider contentProvider;
	private PrologSourceFileModel model;
	private PLEditor editor;
	private ILabelProvider labelProvider;
	private Menu contextMenu;
	//	private StringMatcher matcher;

	public NonNaturePrologOutline(PLEditor editor) {
		this.editor = editor;
	}

	@Override
	public void createControl(Composite parent) {
		super.createControl(parent);

		TreeViewer viewer = getTreeViewer();

		contentProvider = new OutlineContentProvider();
		viewer.setContentProvider(contentProvider);

		labelProvider = new OutlineLabelProvider();

//		labelProvider = new DecoratingLabelProvider(new OutlineLabelProvider(),
//				PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
		viewer.setLabelProvider(labelProvider);

//		viewer.addSelectionChangedListener(this);

		viewer.addDoubleClickListener(this);

		viewer.getControl().addListener(SWT.Show, new Listener() {
			@Override
			public void handleEvent(Event event) {
				getSite().getShell().getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						setInput(null);
					}
				});
			}
		});

		model = new PrologSourceFileModel(new HashMap<String,OutlineModuleElement>());

		viewer.setInput(model);

		viewer.setAutoExpandLevel(EXPANDING_LEVEL);

		IActionBars actionBars = getSite().getActionBars();
		IToolBarManager toolBarManager = actionBars.getToolBarManager();
		//		Action action = new LexicalSortingAction(viewer);
		//		toolBarManager.add(action);
		Action action = new ToggleSortAction(getTreeViewer());
		toolBarManager.add(action);
		ToggleFilterAction action2 = new ToggleFilterAction(
				"Hide private predicates",
				ImageRepository.getImageDescriptor(ImageRepository.PE_PROTECTED),
				ImageRepository.getImageDescriptor(ImageRepository.FILTER_PRIVATE),
				viewer,
				new HidePrivatePredicatesFilter(),
				PDTPlugin.getDefault().getPreferenceStore(),
				PDT.PREF_OUTLINE_FILTER_PRIVATE);
		toolBarManager.add(action2);
		ToggleFilterAction action3 = new ToggleFilterAction(
				"Hide system predicates",
				ImageRepository.getImageDescriptor(ImageRepository.NO_FILTER_SYSTEM),
				ImageRepository.getImageDescriptor(ImageRepository.FILTER_SYSTEM),
				viewer,
				new HideSystemPredicatesFilter(),
				PDTPlugin.getDefault().getPreferenceStore(),
				PDT.PREF_OUTLINE_FILTER_SYSTEM);
		toolBarManager.add(action3);
		//		action = new FilterActionMenu(this);
		//		toolBarManager.add(action);

		hookContextMenu(parent);
		setInput(editor.getEditorInput());

		PDTConnectorPlugin.getDefault().getPrologProcessService().registerConsultListener(this);
		PDTConnectorPlugin.getDefault().getPrologProcessService().registerActivePrologProcessListener(this);
		PDTCommonPlugin.getDefault().registerProcessStartListener(this);
	}

	private void fillContextMenu(IMenuManager manager) {
		// Other plug-ins can contribute their actions here
		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	}

	private void hookContextMenu(Composite parent) {
		MenuManager menuMgr = new MenuManager("#PopupMenu");
		menuMgr.setRemoveAllWhenShown(true);
		menuMgr.addMenuListener(new IMenuListener() {
			@Override
			public void menuAboutToShow(IMenuManager manager) {
				NonNaturePrologOutline.this.fillContextMenu(manager);
			}
		});
		TreeViewer viewer = getTreeViewer();
		getSite().registerContextMenu(MENU_ID,menuMgr, viewer);
		contextMenu = menuMgr.createContextMenu(parent);
		viewer.getControl().setMenu(contextMenu);
	}

	@Override
	public TreeViewer getTreeViewer() {
		return super.getTreeViewer();
	}

	public void setInput(Object information) {
		if (model == null) {
			return;
		}

		String fileName = editor.getPrologFileName();

		Map<String,OutlineModuleElement> modules;
		TreeViewer treeViewer = getTreeViewer();
		if (!fileName.isEmpty()) {
			Object[] expandedElements = null;
			try {
				modules = PDTOutlineQuery.getProgramElementsForFile(fileName);
				model.update(modules, fileName);

				expandedElements = treeViewer.getExpandedElements();
				treeViewer.setInput(model);
				treeViewer.setAutoExpandLevel(EXPANDING_LEVEL);

			} catch(Exception e) {
				Debug.report(e);
			}
			if (treeViewer != null) {
				treeViewer.refresh();
				if (expandedElements != null && expandedElements.length > 0) {
					treeViewer.setExpandedElements(expandedElements);
				}
			}
		}
	}

	@Override
	public void selectionChanged(final SelectionChangedEvent event) {
		super.selectionChanged(event);
		Object elem = getFirstSelectedElement(event);
		OutlinePredicateElement predicate=null;
		String selectedFile = "";
		int line;

		if (elem == null) return;

		if (elem instanceof OutlineModuleElement) {
			OutlineModuleElement module = (OutlineModuleElement)elem;
			line = module.getLine();
			selectedFile = module.getFilePath();
		} else if (elem instanceof OutlinePredicateElement) {
			predicate = (OutlinePredicateElement)elem;
			line = predicate.getLine();
			selectedFile = predicate.getFileName();
		} else if (elem instanceof OutlineClauseElement) {
			OutlineClauseElement occurance = (OutlineClauseElement)elem;
			line = occurance.getLine();
			selectedFile = occurance.getFile();
//			predicate = (OutlinePredicateElement)occurance.getParent();
		} else {
			return;
		}

		String editorFileName = editor.getPrologFileName();
		if (selectedFile.equals(editorFileName)) {
			if (line > 0) {  // line = 0 means we do not have any line information
				editor.gotoLine(line);
			}
		} else {
			// FIXME: ask user if he wants to switch to the other file
			//			IFile file;
			//			try {
			//				file = FileUtils.findFileForLocation(selectedFile);
			//				SourceLocation loc = createLocation(predicate, line, file);
			//				PDTUtils.showSourceLocation(loc);
			//			} catch (IOException e) {
			//			}
		}
	}

	private Object getFirstSelectedElement(final SelectionChangedEvent event) {
		if(event.getSelection().isEmpty()){
			return null;
		}
		if(!(event.getSelection() instanceof IStructuredSelection)){
			return null;
		}
		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
		Object elem = selection.getFirstElement();

		return elem;
	}

	private SourceLocation createLocation(String functor, int arity, int line, IFile file) {
		SourceLocation loc = new SourceLocation(file.getRawLocation().toPortableString(), false);
		loc.isWorkspacePath = file.isAccessible();
		loc.setLine(line);
		loc.setPredicateName(functor);
		loc.setArity(arity);
		return loc;
	}

	@Override
	public void dispose() {
		super.dispose();
		PDTConnectorPlugin.getDefault().getPrologProcessService().unRegisterConsultListener(this);
		PDTConnectorPlugin.getDefault().getPrologProcessService().unRegisterActivePrologProcessListener(this);
		PDTCommonPlugin.getDefault().unregisterProcessStartListener(this);
		contentProvider.dispose();
		model.dispose();
	}

	@Override
	public void beforeConsult(PrologProcess process, List<IFile> files, IProgressMonitor monitor) throws PrologProcessException {
		monitor.beginTask("", 1);
		monitor.done();
	}

	@Override
	public void afterConsult(PrologProcess process, List<IFile> files, List<String> allConsultedFiles, IProgressMonitor monitor) throws PrologProcessException {
		monitor.beginTask("", 1);

		if (process.equals(PDTCommonUtil.getActivePrologProcess())) {
			String editorFile = editor.getPrologFileName();
			if (allConsultedFiles.contains(editorFile)) {
				getSite().getShell().getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						setInput(null);
					}
				});
			}
		}

		monitor.done();
	}

	@Override
	public void activePrologProcessChanged(PrologProcess process) {
		getSite().getShell().getDisplay().asyncExec(new Runnable() {
			@Override
			public void run() {
//				if (model != null && !model.hasChildren()) {
					setInput(null);
//				}
			}
		});
	}

	@Override
	public void prologProcessStarted(PrologProcess process) {
		if (process.equals(PDTCommonUtil.getActivePrologProcess())) {
			getSite().getShell().getDisplay().asyncExec(new Runnable() {
				@Override
				public void run() {
					setInput(null);
				}
			});
		}
	}

	@Override
	public void doubleClick(DoubleClickEvent event) {

		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
		Object elem = selection.getFirstElement();
		if (elem == null) return;

		String functor = null;
		int arity = 0;
		String selectedFile = "";
		int line = 0;

		if (elem instanceof OutlineModuleElement) {
			OutlineModuleElement module = (OutlineModuleElement)elem;
			PrologProcess process = PDTCommonUtil.getActivePrologProcess();
			if ("module".equals(module.getKind())) {
				try {
					Map<String, Object> result = process.queryOnce(bT(PDTPredicates.MODULE_PROPERTY, QueryUtils.quoteAtom(module.getName()), "file(File)"),
							bT(PDTPredicates.MODULE_PROPERTY, QueryUtils.quoteAtom(module.getName()), "line_count(Line)"));
					if (result == null) {
						return;
					} else {
						selectedFile = result.get("File").toString();
						line = Integer.parseInt(result.get("Line").toString());
					}
				} catch (Exception e) {
					Debug.report(e);
					return;
				}
			} else { // logtalk (no modules, but entities)
				try {
					Map<String, Object> result = process.queryOnce(bT(PDTPredicates.ENTITY_PROPERTY, QueryUtils.quoteAtom(module.getName()), "_", "file(FileName, Folder)"),
							bT(PDTPredicates.ENTITY_PROPERTY, QueryUtils.quoteAtom(module.getName()), "_", "lines(Line, _)"));
					if (result == null) {
						return;
					} else {
						selectedFile = result.get("Folder").toString() + result.get("FileName").toString();
						line = Integer.parseInt(result.get("Line").toString());
					}
				} catch (Exception e) {
					Debug.report(e);
					return;
				}
			}
		} else if (elem instanceof OutlinePredicateElement) {
			OutlinePredicateElement predicate = (OutlinePredicateElement)elem;
			line = predicate.getLine();
			selectedFile = predicate.getFileName();
			functor = predicate.getFunctor();
			arity = predicate.getArity();
		} else if (elem instanceof OutlineClauseElement) {
			OutlineClauseElement clause = (OutlineClauseElement)elem;
			line = clause.getLine();
			selectedFile = clause.getFile();
			functor = clause.getFunctor();
			arity = clause.getArity();
		} else if (elem instanceof OutlineFileElement) {
			OutlineFileElement outlineFileElement = (OutlineFileElement) elem;
			line = outlineFileElement.getFirstLine();
			selectedFile = outlineFileElement.getFilePath();
		} else {
			return;
		}

		String editorFileName = editor.getPrologFileName();
		if (!selectedFile.equals(editorFileName)) {

			IFile file;
			try {
				file = FileUtils.findFileForLocation(selectedFile);
				SourceLocation loc = createLocation(functor, arity, line, file);
				PDTCommonUtil.showSourceLocation(loc);
			} catch (IOException e) {
			}
		}
	}
}


text:
@implementation BeeUITableView
// TODO:
@end

#endif	// #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)

redpajama_set_name: RedPajamaGithub


text:
import {
    after as importedAfter,
    before as importedBefore,
    afterEach as importedAfterEach,
    beforeEach as importedBeforeEach,
    describe as importedDescribe,
    it as importedIt,
    xit as importedXit
} from 'mocha';

import LocalMocha = require('mocha');

// Warning!!
// Don't refer node.d.ts!!
// See #22510.
(): number => setTimeout(() => 0, 0);

declare let number: number;
declare let boolean: boolean;
declare let string: string;
declare let stringOrUndefined: string | undefined;
declare let any: any;

// Use module augmentation to add a third-party interface or reporter
declare module 'mocha' {
    interface InterfaceContributions {
        'third-party-interface': never;
    }
    interface ReporterContributions {
        'third-party-reporter': never;
    }
}

const thirdPartyInterface: Mocha.Interface = 'third-party-interface';
const thirdPartyReporter: Mocha.Reporter = 'third-party-reporter';

// Lazy tests of compatibility between imported and global functions; should be identical
const _after: typeof after = importedAfter;
const _after2: typeof importedAfter = after;
const _before: typeof before = importedBefore;
const _before2: typeof importedBefore = before;
const _afterEach: typeof afterEach = importedAfterEach;
const _afterEach2: typeof importedAfterEach = afterEach;
const _beforeEach: typeof beforeEach = importedBeforeEach;
const _beforeEach2: typeof importedBeforeEach = beforeEach;
const _describe: typeof describe = importedDescribe;
const _describe2: typeof importedDescribe = describe;
const _it: typeof it = importedIt;
const _it2: typeof importedIt = it;
const _xit: typeof xit = importedXit;
const _xit2: typeof importedXit = xit;

function test_bdd_describe() {
    // $ExpectType Suite
    describe('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType Suite
    describe.only('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType void | Suite
    describe.skip('something', function() {
        // $ExpectType Suite
        this;
    });
}

function test_bdd_context() {
    // $ExpectType Suite
    context('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType Suite
    context.only('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType void | Suite
    context.skip('something', function() {
        // $ExpectType Suite
        this;
    });
}

function test_bdd_xdescribe() {
    // $ExpectType void | Suite
    xdescribe('something', function() {
        // $ExpectType Suite
        this;
    });
}

function test_bdd_xcontext() {
    // $ExpectType void | Suite
    xcontext('something', function() {
        // $ExpectType Suite
        this;
    });
}

function test_tdd_suite() {
    // $ExpectType Suite
    suite('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType Suite
    suite.only('something', function() {
        // $ExpectType Suite
        this;
    });

    // $ExpectType void | Suite
    suite.skip('something', function() {
        // $ExpectType Suite
        this;
    });
}

function test_qunit_suite() {
    // $ExpectType Suite
    suite('some context');

    // $ExpectType Suite
    suite.only('some context');
}

function test_bdd_it() {
    // $ExpectType Test
    it(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.only(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.only(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.only('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.only('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.skip(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.skip(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.skip('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    it.skip('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType void
    it.retries(number);
}

function test_bdd_xit() {
    // $ExpectType Test
    xit(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xit(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xit('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xit('does something', async function() {
        // $ExpectType Context
        this;
    });
}

function test_bdd_specify() {
    // $ExpectType Test
    specify(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.only(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.only(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.only('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.only('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.skip(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.skip(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.skip('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    specify.skip('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType void
    specify.retries(number);
}

function test_bdd_xspecify() {
    // $ExpectType Test
    xspecify(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xspecify(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xspecify('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    xspecify('does something', async function() {
        // $ExpectType Context
        this;
    });
}

function test_tdd_qunit_test() {
    // $ExpectType Test
    test(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.only(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.only(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.only('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.only('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.skip(function doesSomething(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.skip(async function doesSomething() {
        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.skip('does something', function(done) {
        // $ExpectType Done
        done;

        // $ExpectType Context
        this;
    });

    // $ExpectType Test
    test.skip('does something', async function() {
        // $ExpectType Context
        this;
    });

    // $ExpectType void
    test.retries(number);
}

function test_bdd_qunit_before() {
    before(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    before(async function() {
        // $ExpectType Context
        this;
    });

    before('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    before('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_tdd_setup() {
    setup(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    setup(async function() {
        // $ExpectType Context
        this;
    });

    setup('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    setup('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_bdd_qunit_after() {
    after(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    after(async function() {
        // $ExpectType Context
        this;
    });

    after('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    after('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_tdd_teardown() {
    teardown(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    teardown(async function() {
        // $ExpectType Context
        this;
    });

    teardown('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    teardown('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_bdd_qunit_beforeEach() {
    beforeEach(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    beforeEach(async function() {
        // $ExpectType Context
        this;
    });

    beforeEach('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    beforeEach('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_tdd_suiteSetup() {
    suiteSetup(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    suiteSetup(async function() {
        // $ExpectType Context
        this;
    });

    suiteSetup('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    suiteSetup('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_bdd_qunit_afterEach() {
    afterEach(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    afterEach(async function() {
        // $ExpectType Context
        this;
    });

    afterEach('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    afterEach('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_tdd_suiteTeardown() {
    suiteTeardown(function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    suiteTeardown(async function() {
        // $ExpectType Context
        this;
    });

    suiteTeardown('description', function(done) {
        // $ExpectType Done
        done;
        // $ExpectType Context
        this;
    });

    suiteTeardown('description', async function() {
        // $ExpectType Context
        this;
    });
}

function test_Context(ctx: LocalMocha.Context, runnable: LocalMocha.Runnable) {
    // $ExpectType never
    ctx.skip(); // throws

    // $ExpectType boolean
    ctx.enableTimeouts();

    // $ExpectType Context
    ctx.enableTimeouts(boolean);

    // $ExpectType number
    ctx.retries();

    // $ExpectType Context
    ctx.retries(number);

    // $ExpectType Runnable
    ctx.runnable();

    // $ExpectType Context
    ctx.runnable(runnable);

    // $ExpectType number
    ctx.slow();

    // $ExpectType Context
    ctx.slow(number);

    // $ExpectType number
    ctx.timeout();

    // $ExpectType Context
    ctx.timeout(number);

    // $ExpectType Test | undefined
    ctx.currentTest;

    // $ExpectType Runnable | undefined
    ctx.test;

    ctx["extended"] = any;

    // $ExpectType any
    ctx["extended"];

    ctx.enableTimeouts(boolean)
        .retries(number)
        .runnable(runnable)
        .slow(number)
        .timeout(number)
        .skip();
}

function test_reporter_string(localMocha: LocalMocha) {
    // $ExpectType BrowserMocha
    mocha.reporter('html');

    const m: Mocha = localMocha.reporter('html');
}

function test_reporter_function(localMocha: LocalMocha) {
    // $ExpectType BrowserMocha
    mocha.reporter(class extends LocalMocha.reporters.Base { });

    const m: Mocha = localMocha.reporter(class extends LocalMocha.reporters.Base { });
}

function test_browser_mocha_setup_slow_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ slow: 25 });
}

function test_browser_mocha_setup_timeout_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ timeout: 25 });
}

function test_browser_mocha_setup_globals_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ globals: ['mocha'] });
}

function test_browser_mocha_setup_ui_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ ui: 'bdd' });
}

function test_browser_mocha_setup_reporter_string_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ reporter: 'html' });
}

function test_browser_mocha_setup_require_stringArray_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ require: ['ts-node/register'] });
}

function test_browser_mocha_setup_reporter_function_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ reporter: class extends LocalMocha.reporters.Base { } });
}

function test_browser_mocha_setup_bail_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ bail: false });
}

function test_browser_mocha_setup_ignore_leaks_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ ignoreLeaks: false });
}

function test_browser_mocha_setup_grep_string_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ grep: "describe" });
}

function test_browser_mocha_setup_grep_regex_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ grep: new RegExp('describe') });
}

function test_browser_mocha_setup_grep_regex_literal_option() {
    // $ExpectType BrowserMocha
    mocha.setup({ grep: /(expect|should)/i });
}

function test_browser_mocha_setup_all_options() {
    // $ExpectType BrowserMocha
    mocha.setup({
        slow: 25,
        timeout: 25,
        ui: 'bdd',
        globals: ['mocha'],
        reporter: 'html',
        bail: true,
        ignoreLeaks: true,
        grep: 'test',
        require: ['ts-node/register'] // TODO: It doesn't appear this is actually supported. Should it be removed?
    });
}

function test_constructor_slow_option() {
    const m: Mocha = new LocalMocha({ slow: 25 });
}

function test_constructor_timeout_option() {
    const m: Mocha = new LocalMocha({ timeout: 25 });
}

function test_constructor_globals_option() {
    const m: Mocha = new LocalMocha({ globals: ['mocha'] });
}

function test_constructor_ui_option() {
    const m: Mocha = new LocalMocha({ ui: 'bdd' });
}

function test_constructor_reporter_string_option() {
    const m: Mocha = new LocalMocha({ reporter: 'html' });
}

function test_constructor_reporter_function_option() {
    const m: Mocha = new LocalMocha({ reporter: class extends LocalMocha.reporters.Base { } });
}

function test_constructor_bail_option() {
    const m: Mocha = new LocalMocha({ bail: false });
}

function test_constructor_ignore_leaks_option() {
    const m: Mocha = new LocalMocha({ ignoreLeaks: false });
}

function test_constructor_grep_string_option() {
    const m: Mocha = new LocalMocha({ grep: "describe" });
}

function test_constructor_grep_regex_option() {
    const m: Mocha = new LocalMocha({ grep: new RegExp('describe') });
}

function test_constructor_grep_regex_literal_option() {
    const m: Mocha = new LocalMocha({ grep: /(expect|should)/i });
}

function test_constructor_all_options() {
    const m: Mocha = new LocalMocha({
        slow: 25,
        timeout: 25,
        ui: 'bdd',
        globals: ['mocha'],
        reporter: 'html',
        bail: true,
        ignoreLeaks: true,
        grep: 'test'
    });
}

function test_run(localMocha: LocalMocha) {
    // $ExpectType Runner
    mocha.run();

    // $ExpectType Runner
    mocha.run((failures) => {
        // $ExpectType number
        failures;
    });

    // $ExpectType Runner
    localMocha.run();

    // $ExpectType Runner
    localMocha.run((failures) => {
        // $ExpectType number
        failures;
    });
}

function test_growl() {
    mocha.growl();
}

function test_chaining() {
    new LocalMocha({ slow: 25 })
        .growl()
        .reporter('html')
        .reporter(class extends LocalMocha.reporters.Base { });
}

function test_require_constructor_empty() {
    const instance = new LocalMocha();
}

function test_require_constructor_noOptions() {
    const instance = new LocalMocha({});
}

function test_require_constructor_allOptions() {
    const instance = new LocalMocha({
        grep: /[a-z]*/,
        ui: 'tdd',
        reporter: 'dot',
        timeout: 500,
        bail: true
    });
}

function test_require_fluentParams() {
    const instance = new LocalMocha();

    instance.bail(true)
        .bail()
        .addFile('foo.js')
        .reporter('dot')
        .ui('bdd')
        .grep('[a-z]*')
        .grep(/[a-z]*/)
        .invert()
        .ignoreLeaks(true)
        .checkLeaks()
        .growl()
        .globals('foo')
        .globals(['bar', 'zap'])
        .useColors(true)
        .useInlineDiffs(true)
        .timeout(500)
        .slow(100)
        .enableTimeouts(true)
        .asyncOnly()
        .noHighlighting()
        .run();
}

function test_throwError() {
    mocha.throwError(new Error("I'm an error!"));
}

function test_mochaRunner_properties(runner: LocalMocha.Runner, suite: LocalMocha.Suite) {
    // $Expecttype Runner
    runner.abort();

    // $ExpectType Suite
    runner.suite;

    // $ExpectType boolean
    runner.started;

    // $ExpectType number
    runner.total;

    // $ExpectType number
    runner.failures;

    // $ExpectType Runner
    runner.grep(/regex/, false);

    // $ExpectType number
    runner.grepTotal(suite);

    // $ExpectType string[]
    runner.globals();

    // $ExpectType Runner
    runner.globals(["hello", "world"]);

    // $ExpectType Runner
    runner.run();

    // $ExpectType Runner
    runner.run((failures) => {
        // $ExpectType number
        failures;
    });
}

function test_base_reporter_properties(reporter: LocalMocha.reporters.Base) {
    // $ExpectType number
    reporter.stats.failures;

    // $ExpectType number
    reporter.stats.passes;

    // $ExpectType number
    reporter.stats.pending;

    // $ExpectType number
    reporter.stats.suites;

    // $ExpectType number
    reporter.stats.tests;

    // $ExpectType Date | undefined
    reporter.stats.start;

    // $ExpectType Date | undefined
    reporter.stats.end;

    // $ExpectType number | undefined
    reporter.stats.duration;
}

function test_runner_events(runner: LocalMocha.Runner) {
    // $ExpectType Runner
    runner.on("start", () => {});

    // $ExpectType Runner
    runner.on("end", () => {});

    // $ExpectType Runner
    runner.on("suite", (suite) => {
        // $ExpectType Suite
        suite;
    });

    // $ExpectType Runner
    runner.on("suite end", (suite) => {
        // $ExpectType Suite
        suite;
    });

    // $ExpectType Runner
    runner.on("test", (test) => {
        // $ExpectType Test
        test;
    });

    // $ExpectType Runner
    runner.on("test end", (test) => {
        // $ExpectType Test
        test;
    });

    // $ExpectType Runner
    runner.on("hook", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Runner
    runner.on("hook end", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Runner
    runner.on("pass", (test) => {
        // $ExpectType Test
        test;
    });

    // $ExpectType Runner
    runner.on("fail", (test, err) => {
        // $ExpectType Test
        test;

        // $ExpectType any
        err;
    });

    // $ExpectType Runner
    runner.on("pending", (test) => {
        // $ExpectType Test
        test;
    });
}

function test_runnable_events(runnable: LocalMocha.Runnable) {
    // $ExpectType Runnable
    runnable.on("error", (error) => {
        // $ExpectType any
        error;
    });
}

function test_suite_events(suite: LocalMocha.Suite) {
    // $ExpectType Suite
    suite.on("beforeAll", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Suite
    suite.on("afterAll", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Suite
    suite.on("beforeEach", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Suite
    suite.on("afterEach", (hook) => {
        // $ExpectType Hook
        hook;
    });

    // $ExpectType Suite
    suite.on("run", () => { });

    // $ExpectType Suite
    suite.on("pre-require", (context, file, mocha) => {
        // $ExpectType MochaGlobals
        context;
        // $ExpectType string
        file;
        const m: Mocha = mocha;
    });

    // $ExpectType Suite
    suite.on("require", (module, file, mocha) => {
        // $ExpectType any
        module;
        // $ExpectType string
        file;
        const m: Mocha = mocha;
    });

    // $ExpectType Suite
    suite.on("post-require", (context, file, mocha) => {
        // $ExpectType MochaGlobals
        context;
        // $ExpectType string
        file;
        const m: Mocha = mocha;
    });
}

function test_backcompat_Suite(suite: Mocha.Suite, iSuite: Mocha.ISuite, iSuiteContext: Mocha.ISuiteCallbackContext, iTest: Mocha.ITest, iContext: Mocha.IContext) {
    iSuite = suite;
    iSuiteContext = suite;
    suite.addTest(iTest);
    suite.addSuite(iSuite);
    LocalMocha.Suite.create(iSuite, string);
    new LocalMocha.Suite(string, iContext);
}

function test_backcompat_Runner(runner: Mocha.Runner, iRunner: Mocha.IRunner, iSuite: Mocha.ISuite) {
    iRunner = runner;
    runner.grepTotal(iSuite);
}

function test_backcompat_Runnable(runnable: Mocha.Runnable, iRunnable: Mocha.IRunnable) {
    iRunnable = runnable;
}

function test_backcompat_Test(test: Mocha.Test, iTest: Mocha.ITest) {
    iTest = test;
}

function test_backcompat_Hook(hook: Mocha.Hook, iHook: Mocha.IHook) {
    iHook = hook;
}

function test_backcompat_Context(context: Mocha.Context, iContext: Mocha.IContext,
    iHookContext: Mocha.IHookCallbackContext, iBeforeAfterContext: Mocha.IBeforeAndAfterContext,
    iTestContext: Mocha.ITestCallbackContext, iRunnable: Mocha.IRunnable) {
    iContext = context;
    iHookContext = context;
    iBeforeAfterContext = context;
    iTestContext = context;
    context.runnable(iRunnable);
}

function test_backcompat_Base(iRunner: Mocha.IRunner) {
    new LocalMocha.reporters.Base(iRunner);
}

function test_backcompat_XUnit(iRunner: Mocha.IRunner) {
    new LocalMocha.reporters.XUnit(iRunner);
}

function test_backcompat_Progress(iRunner: Mocha.IRunner) {
    new LocalMocha.reporters.Progress(iRunner);
}

import common = require("mocha/lib/interfaces/common");

function test_interfaces_common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, localMocha: Mocha,
    fn: Mocha.Func | Mocha.AsyncFunc, test: Mocha.Test) {
    const funcs = common(suites, context, localMocha);
    // $ExpectType CommonFunctions
    funcs;

    funcs.before(fn);
    funcs.before(string, fn);
    funcs.beforeEach(fn);
    funcs.beforeEach(string, fn);
    funcs.after(fn);
    funcs.after(string, fn);
    funcs.afterEach(fn);
    funcs.afterEach(string, fn);

    // $ExpectType Suite
    funcs.suite.create({ title: string });
    funcs.suite.create({ title: string, file: string, fn: () => {}, pending: boolean, isOnly: boolean });

    // $ExpectType Suite
    funcs.suite.only({ title: string });
    funcs.suite.only({ title: string, file: string, fn: () => {}, pending: boolean, isOnly: boolean });

    // $ExpectType Suite
    funcs.suite.skip({ title: string });
    funcs.suite.skip({ title: string, file: string, fn: () => {}, pending: boolean, isOnly: boolean });

    // $ExpectType Test
    funcs.test.only(mocha, test);
    funcs.test.skip(string);
    funcs.test.retries(number);
}

// mocha-typescript (https://www.npmjs.com/package/mocha-typescript/) augments
// the mocha functions and enables them to work as test class decorators.
declare module "mocha" {
    interface SuiteFunction {
        <TFunction extends Function>(target: TFunction): TFunction | void;
    }
    interface PendingSuiteFunction {
        <TFunction extends Function>(target: TFunction): TFunction | void;
    }
    interface ExclusiveSuiteFunction {
        <TFunction extends Function>(target: TFunction): TFunction | void;
    }
    interface TestFunction {
        (target: Object, propertyKey: string | symbol): void;
    }
    interface PendingTestFunction {
        (target: Object, propertyKey: string | symbol): void;
    }
    interface ExclusiveTestFunction {
        (target: Object, propertyKey: string | symbol): void;
    }
}

@suite
class TestClass1 {
    @test method1() {}
    @test.only method2() {}
    @test.skip method3() {}
}

@suite.skip
class TestClass2 {
}

@suite.only
class TestClass3 {
}
// end of augmentations used by mocha-typescript


text:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// application modules
import { CommercialModule } from './commercial/commercial.module';
import { SamplesModule } from './samples/samples.module';
import { SharedModule } from './shared/shared.module';
import { CoreModule } from './core/core.module';

// application components
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [

    // angular modules
    BrowserModule,
    HttpModule,
    RouterModule,
    BrowserAnimationsModule,

    // application modules
    CommercialModule,
    SamplesModule,
    SharedModule,
    CoreModule

  ],
  providers: [
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }


text:
package org.apache.camel.management;

import javax.management.MBeanServer;
import javax.management.ObjectName;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;

/**
 * @version $Revision: 980370 $
 */
public class ManagedCamelContextSuspendStartTest extends ManagementTestSupport {

    public void testManagedCamelContext() throws Exception {
        MBeanServer mbeanServer = getMBeanServer();

        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");

        assertTrue("Should be registered", mbeanServer.isRegistered(on));
        String name = (String) mbeanServer.getAttribute(on, "CamelId");
        assertEquals("camel-1", name);

        String uptime = (String) mbeanServer.getAttribute(on, "Uptime");
        assertNotNull(uptime);

        String status = (String) mbeanServer.getAttribute(on, "State");
        assertEquals("Started", status);

        // invoke operations
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello World");

        Object reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello World"}, new String[]{"java.lang.String", "java.lang.String"});
        assertEquals("Bye World", reply);

        // suspend Camel
        mbeanServer.invoke(on, "suspend", null, null);

        status = (String) mbeanServer.getAttribute(on, "State");
        assertEquals("Suspended", status);

        // start Camel
        mbeanServer.invoke(on, "start", null, null);

        status = (String) mbeanServer.getAttribute(on, "State");
        assertEquals("Started", status);

        reply = mbeanServer.invoke(on, "requestBody", new Object[]{"direct:foo", "Hello Camel"}, new String[]{"java.lang.String", "java.lang.String"});
        assertEquals("Bye World", reply);
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:foo").transform(constant("Bye World"));
            }
        };
    }

}


text:
using Medallion.Threading.Internal;
using Medallion.Threading.Tests.Data;
using System.Data;
using System.Data.Common;

namespace Medallion.Threading.Tests.SqlServer;

public interface ITestingSqlServerDb { }

public sealed class TestingSqlServerDb : TestingPrimaryClientDb, ITestingSqlServerDb
{
    internal static readonly string DefaultConnectionString = SqlServerCredentials.ConnectionString;

    private readonly Microsoft.Data.SqlClient.SqlConnectionStringBuilder _connectionStringBuilder =
        new Microsoft.Data.SqlClient.SqlConnectionStringBuilder(DefaultConnectionString);

    public override DbConnectionStringBuilder ConnectionStringBuilder => this._connectionStringBuilder;

    // https://stackoverflow.com/questions/5808332/sql-server-maximum-character-length-of-object-names/41502228
    public override int MaxApplicationNameLength => 128;

    public override TransactionSupport TransactionSupport => TransactionSupport.TransactionScoped;

    public override int CountActiveSessions(string applicationName)
    {
        Invariant.Require(applicationName.Length <= this.MaxApplicationNameLength);

        using var connection = new Microsoft.Data.SqlClient.SqlConnection(DefaultConnectionString);
        connection.Open();
        using var command = connection.CreateCommand();
        command.CommandText = $@"SELECT COUNT(*) FROM sys.dm_exec_sessions WHERE program_name = @applicationName";
        command.Parameters.AddWithValue("applicationName", applicationName);
        return (int)command.ExecuteScalar();
    }

    public override IsolationLevel GetIsolationLevel(DbConnection connection)
    {
        using var command = connection.CreateCommand();
        command.CommandText = @"
                SELECT CASE transaction_isolation_level
                    WHEN 0 THEN 'Unspecified'
                    WHEN 1 THEN 'ReadUncommitted'
                    WHEN 2 THEN 'ReadCommitted'
                    WHEN 3 THEN 'RepeatableRead'
                    WHEN 4 THEN 'Serializable'
                    WHEN 5 THEN 'Snapshot'
                    ELSE 'Unknown' END AS isolationLevel
                FROM sys.dm_exec_sessions
                WHERE session_id = @@SPID";
        return (IsolationLevel)Enum.Parse(typeof(IsolationLevel), (string)command.ExecuteScalar());
    }

    public override DbConnection CreateConnection() => new Microsoft.Data.SqlClient.SqlConnection(this.ConnectionStringBuilder.ConnectionString);

    public override async Task KillSessionsAsync(string applicationName, DateTimeOffset? idleSince)
    {
        using var connection = new Microsoft.Data.SqlClient.SqlConnection(DefaultConnectionString);
        await connection.OpenAsync();

        var findIdleSessionsCommand = connection.CreateCommand();
        findIdleSessionsCommand.CommandText = @"
                SELECT session_id FROM sys.dm_exec_sessions
                WHERE session_id != @@SPID
                    AND program_name = @applicationName
                    AND (
                        @idleSince IS NULL
                        OR (
                            (last_request_start_time IS NULL OR last_request_start_time <= @idleSince)
                            AND (last_request_end_time IS NULL OR last_request_end_time <= @idleSince)
                        )
                    )";
        findIdleSessionsCommand.Parameters.AddWithValue("applicationName", applicationName);
        findIdleSessionsCommand.Parameters.AddWithValue("idleSince", idleSince?.DateTime ?? DBNull.Value.As<object>()).SqlDbType = SqlDbType.DateTime;

        var spidsToKill = new List<short>();
        using (var idleSessionsReader = await findIdleSessionsCommand.ExecuteReaderAsync())
        {
            while (await idleSessionsReader.ReadAsync())
            {
                spidsToKill.Add(idleSessionsReader.GetInt16(0));
            }
        }

        foreach (var spid in spidsToKill)
        {
            using var killCommand = connection.CreateCommand();
            killCommand.CommandText = "KILL " + spid;
            try { await killCommand.ExecuteNonQueryAsync(); }
            catch (Exception ex) { Console.WriteLine($"Failed to kill {spid}: {ex}"); }
        }
    }
}

public sealed class TestingSystemDataSqlServerDb : TestingDb, ITestingSqlServerDb
{
    private readonly System.Data.SqlClient.SqlConnectionStringBuilder _connectionStringBuilder =
        new System.Data.SqlClient.SqlConnectionStringBuilder(TestingSqlServerDb.DefaultConnectionString);

    public override DbConnectionStringBuilder ConnectionStringBuilder => this._connectionStringBuilder;

    public override int MaxApplicationNameLength => new TestingSqlServerDb().MaxApplicationNameLength;

    public override TransactionSupport TransactionSupport => TransactionSupport.TransactionScoped;

    public override int CountActiveSessions(string applicationName) => new TestingSqlServerDb().CountActiveSessions(applicationName);

    public override IsolationLevel GetIsolationLevel(DbConnection connection) => new TestingSqlServerDb().GetIsolationLevel(connection);

    public override DbConnection CreateConnection() => new System.Data.SqlClient.SqlConnection(this.ConnectionStringBuilder.ConnectionString);
}


text:
'use strict'

var mqtt = require('mqtt')

var clientId = 'mqttjs_' + Math.random().toString(16).substr(2, 8)

var host = 'wss://localhost:3001/Mosca'

var options = {
  keepalive: 10,
  clientId: clientId,
  protocolId: 'MQTT',
  protocolVersion: 4,
  clean: true,
  reconnectPeriod: 1000,
  connectTimeout: 30 * 1000,
  will: {
    topic: 'WillMsg',
    payload: 'Connection Closed abnormally..!',
    qos: 0,
    retain: false
  },
  username: 'demo',
  password: 'demo',
  rejectUnauthorized: false
}

var client = mqtt.connect(host, options)

client.on('error', function (err) {
  console.log(err)
  client.end()
})

client.on('connect', function () {
  console.log('client connected:' + clientId)
})

client.subscribe('topic', { qos: 0 })

client.publish('topic', 'wss secure connection demo...!', { qos: 0, retained: false })

client.on('message', function (topic, message, packet) {
  console.log('Received Message:= ' + message.toString() + '\nOn topic:= ' + topic)
})

client.on('close', function () {
  console.log(clientId + ' disconnected')
})