Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Created December 21, 2018 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonysneed/1210a61f002db9188bb6ca704cd41a0a to your computer and use it in GitHub Desktop.
Save tonysneed/1210a61f002db9188bb6ca704cd41a0a to your computer and use it in GitHub Desktop.
[Fact]
public async void Function_Should_Return_Product_By_Id()
{
// Mock IProductRepository
var expected = new Product
{
Id = 1,
ProductName = "Chai",
UnitPrice = 10
};
var mockRepo = new Mock<IProductRepository>();
mockRepo.Setup(m => m.GetProduct(It.IsAny<int>())).ReturnsAsync(expected);
// Invoke the lambda function and confirm correct value is returned
var function = new Function(mockRepo.Object);
var result = await function.FunctionHandler("1", new TestLambdaContext());
Assert.Equal(expected, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment