Skip to content

Instantly share code, notes, and snippets.

@Flayed
Last active March 11, 2018 18:05
Show Gist options
  • Select an option

  • Save Flayed/86a8e17a94e7832fef0ee7f416aaae15 to your computer and use it in GitHub Desktop.

Select an option

Save Flayed/86a8e17a94e7832fef0ee7f416aaae15 to your computer and use it in GitHub Desktop.
MyServiceTests with Provide
public class MyServiceTests : TestBase
{
[Fact(DisplayName = "CalculateDistance should get the addresses from the address service")]
public async Task CalculateDistance_LooksUpAddressesInAddressService()
{
double expected = 15623.32944;
Mock.Mock<IAddressService>().SetupGet(x => x.GetAddress(It.IsAny<string>())).ReturnsAsync("123 Fake St, Duck, WV, 25063");
Provide<IDistanceCalculationService, DistanceCalculationService>();
var myService = Mock.Create<MyService>();
double distance = await myService.GetDistance("Duck");
distance.Should().Be(expected);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment