示例#1
0
        public void ValidateTask_Throws_WhenActivityFunctionHasNoProperBinding(
            string bindingType, BindingInfo.Types.Direction bindingDirection)
        {
            var history = CreateHistory(scheduled: false, completed: false, output: InvocationResultJson);
            var orchestrationContext = new OrchestrationContext {
                History = history
            };

            var loadedFunctions = new[]
            {
                DurableTestUtilities.CreateFakeAzFunctionInfo(FunctionName, "fakeTriggerBindingName", bindingType, bindingDirection)
            };

            var durableTaskHandler = new DurableTaskHandler();

            var exception =
                Assert.Throws <InvalidOperationException>(
                    () => ActivityInvocationTask.ValidateTask(
                        new ActivityInvocationTask(FunctionName, FunctionInput), loadedFunctions));

            Assert.Contains(FunctionName, exception.Message);
            Assert.Contains(ActivityTriggerBindingType, exception.Message);

            DurableTestUtilities.VerifyNoActionAdded(orchestrationContext);
        }
        public void ReplayActivityOrStop_Throws_WhenActivityFunctionHasNoProperBinding(
            string bindingType, BindingInfo.Types.Direction bindingDirection)
        {
            var history = CreateHistory(scheduled: false, completed: false, output: InvocationResultJson);
            var orchestrationContext = new OrchestrationContext {
                History = history
            };

            var loadedFunctions = new[]
            {
                CreateFakeAzFunctionInfo(FunctionName, "fakeTriggerBindingName", bindingType, bindingDirection)
            };

            var activityInvocationTracker = new ActivityInvocationTracker();

            var exception =
                Assert.Throws <InvalidOperationException>(
                    () => activityInvocationTracker.ReplayActivityOrStop(
                        FunctionName, FunctionInput, orchestrationContext, loadedFunctions, noWait: false,
                        _ => { Assert.True(false, "Unexpected output"); }));

            Assert.Contains(FunctionName, exception.Message);
            Assert.Contains(ActivityTriggerBindingType, exception.Message);

            VerifyNoCallActivityActionAdded(orchestrationContext);
        }
 private static AzFunctionInfo CreateFakeAzFunctionInfo(
     string functionName,
     string bindingName,
     string bindingType,
     BindingInfo.Types.Direction bindingDirection)
 {
     return(new AzFunctionInfo(
                functionName,
                new ReadOnlyDictionary <string, ReadOnlyBindingInfo>(
                    new Dictionary <string, ReadOnlyBindingInfo>
     {
         {
             bindingName,
             new ReadOnlyBindingInfo(bindingType, bindingDirection)
         }
     })));
 }
 internal ReadOnlyBindingInfo(string type, BindingInfo.Types.Direction direction)
 {
     Type      = type;
     Direction = direction;
 }