Skip to content

Instantly share code, notes, and snippets.

@explorer14

explorer14/ForexCalcTest.cs Secret

Last active Jun 21, 2020
Embed
What would you like to do?
[Fact]
public void ShouldUseForexRateToCalculatePortfolioPosition()
{
// set up a stub to return a value that should be used in the calculation
var forexRateRetriever = new Mock<IRetrieveForexRates>();
forexRateRetriever
.Setup(x=>
x.GetCurrentRateFor(
It.IsAny<SourceCurrency>(),
It.IsAny<DestinationCurrency>())
.Returns(new ForexRate(ratio:1.13m,...);
// the SUT can have other dependencies that could be stubbed/mocked/faked/dummied
// appropriately
var portfolioValueCalculator = CreateSUT(forexRateRetriever.Object,...);
var portfolioValue = portfolioValueCalculator.Calculate();
// if the forexRateRetriever wasn't being used correctly, this assertion will fail
portfolioValue.PositionTotal.Should().Be(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.