public async Task SendMessage_ReturnValue() { var input = new DaprBindingMessage("hello", new Dictionary <string, object> { { "key", "myKey" } }, "myBinding", "create"); await this.CallFunctionAsync(nameof(Functions.DaprConnectorReturnValueAnyMessage), "input", input); SavedHttpRequest req = this.GetSingleSendMessgaeRequest(); JObject expectedPayload = JObject.Parse($@"{{""data"": ""hello"", ""operation"": ""create"", ""metadata"": {{""key"": ""myKey""}}}}"); Assert.Equal("/v1.0/bindings/myBinding", req.Path); Assert.Equal(JsonConvert.SerializeObject(expectedPayload), req.ContentAsString); }
public async Task SendMessage_NoOperationSpecified() { // No operation is specified in the attribute or in the message var input = new DaprBindingMessage("Hello, world!", new Dictionary <string, object> { { "key", "myKey" } }, binding: "bindingName"); FunctionInvocationException error = await Assert.ThrowsAsync <FunctionInvocationException>(() => this.CallFunctionAsync(nameof(Functions.DaprConnectorReturnValueAnyMessage), "input", input)); // The exception message should reflect the fact that no operation was specified ArgumentException innerError = Assert.IsType <ArgumentException>(error.GetBaseException()); Assert.Contains("A non-null operation must be specified", innerError.Message); // No requests should have been sent Assert.Empty(this.GetDaprRequests()); }
public static DaprBindingMessage DaprConnectorReturnValueAnyMessage(DaprBindingMessage input) => input;