Skip to content

Instantly share code, notes, and snippets.

View ffMathy's full-sized avatar
🦄

Mathias Lykkegaard Lorenzen ffMathy

🦄
View GitHub Profile
@ffMathy
ffMathy / CleanupMergedBranchesInGit.bat
Last active March 21, 2023 09:55
Cleans up branches that have been merged in to either develop or master remotely.
powershell.exe -Command "git fetch --all; git branch --merged | ForEach-Object { $_.Trim() } | Where-Object {$_ -NotMatch \"^\*\"} | Where-Object {-not ( $_ -Like \"*master\" -or $_ -Like \"*main\" -or $_ -Like \"*develop\" )} | ForEach-Object { git branch -d $_ }; git fetch --all; git remote prune origin; git fetch --all"
const mockedCalculator = Substitute.for<RealCalculator>();
mockedCalculator.add(1, 2);
mockedCalculator.received(1).add(1, 2); //called exactly once
mockedCalculator.received().add(1, 2); //called at least once
const mockedCalculator = mock(RealCalculator);
const calculator = instance(mockedCalculator);
calculator.add(1, 2);
verify(mockedCalculator.add(1, 2)).once(); //called exactly once
verify(mockedCalculator.add(1, 2)).atLeast(0); //called at least once
const mockedCalculator = TypeMoq.Mock.ofType(RealCalculator);
const calculator = mockedCalculator.object;
calculator.add(1, 2);
mockedCalculator.verify(x => x.add(1, 2), TypeMoq.Times.once()); //called exactly once
mockedCalculator.verify(x => x.add(1, 2), TypeMoq.Times.atLeastOnce()); //called at least once
//no need for two objects
const mockedCalculator = Substitute.for<RealCalculator>();
const mockedCalculator = mock(RealCalculator);
const calculator = instance(mockedCalculator);
const mockedCalculator = TypeMoq.Mock.ofType(RealCalculator);
const calculator = mockedCalculator.object;
const mockedCalculator = Substitute.for<CalculatorInterface>();
const mockedCalculator = Substitute.for<RealCalculator>();
mockedCalculator.add(3, 4);
mockedCalculator.received().add(1, 2);
const mockedCalculator = mock(RealCalculator);
const calculator = instance(mockedCalculator);
calculator.add(3, 4);
verify(mockedCalculator.add(1, 2)).called();