Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Created December 16, 2018 22:49
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/0dcbb31800619cedefeb44febb07d257 to your computer and use it in GitHub Desktop.
Save tonysneed/0dcbb31800619cedefeb44febb07d257 to your computer and use it in GitHub Desktop.
Function Test 1
public class FunctionTest
{
[Fact]
public void Function_Should_Return_Config_Variable()
{
// Mock IConfiguration
var expected = "val1";
var mockConfig = new Mock<IConfiguration>();
mockConfig.Setup(p => p[It.IsAny<string>()]).Returns(expected);
// Mock IConfigurationService
var mockConfigService = new Mock<IConfigurationService>();
mockConfigService.Setup(p => p.GetConfiguration()).Returns(mockConfig.Object);
// Invoke the lambda function and confirm config value is returned
var function = new Function(mockConfigService.Object);
var result = function.FunctionHandler("env1", new TestLambdaContext());
Assert.Equal(expected, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment