public void Test_WebMethod_Post_With_Json_Config() { WebMethods.ConfigurationBuilderFunc = (context, builder) => builder.AddJsonFile("testconfig.json", false); WebMethods = new WebMethods(); Assert.Equal("TESTACCESSKEY", WebMethods.awsCredentials.AccessKey); Assert.Equal("TESTSECRETKEY", WebMethods.awsCredentials.SecretKey); Assert.Equal("arn:aws:sns:us-east-1:TEST:TestFeed", WebMethods.awsSns.Topic); var response = WebMethods.Post(RequestMock.Object, ContextMock.Object); Assert.Equal((int)HttpStatusCode.OK, response.StatusCode); SnsMock.Verify(); }
public void Test_WebMethod_Post_With_Environment_Config() { Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Production"); Environment.SetEnvironmentVariable("WEBHOOK_AWSCREDENTIALS:ACCESSKEY", "TestAccessKey"); Environment.SetEnvironmentVariable("WEBHOOK_AWSCREDENTIALS:SECRETKEY", "TestSecretKey"); Environment.SetEnvironmentVariable("WEBHOOK_AWSSNS:TOPIC", "TestSnsTopic"); WebMethods.ConfigurationBuilderFunc = (context, builder) => builder.AddEnvironmentVariables("WEBHOOK_"); WebMethods = new WebMethods(); Assert.Equal("TestAccessKey", WebMethods.awsCredentials.AccessKey); Assert.Equal("TestSecretKey", WebMethods.awsCredentials.SecretKey); Assert.Equal("TestSnsTopic", WebMethods.awsSns.Topic); var response = WebMethods.Post(RequestMock.Object, ContextMock.Object); Assert.Equal((int)HttpStatusCode.OK, response.StatusCode); SnsMock.Verify(); }