public async Task AddTaskAsyncShouldReturnPostedResult() { var functionsManager = new FunctionsManager("component", "statemachine"); var xcEvent = new object(); var publicMember = new object(); var internalMember = new object(); var context = new object(); var sender = Substitute.For <ISender>(); var task = functionsManager.AddTaskAsync(xcEvent, publicMember, internalMember, context, sender, "function"); var enqueuedParameter = functionsManager.GetTask(); var functionResult = new FunctionResult() { ComponentName = "component", StateMachineName = "statemachine", PublicMember = "{}", InternalMember = "{}", Senders = null, RequestId = enqueuedParameter.RequestId, }; functionsManager.AddTaskResult(functionResult); var publishedResult = await task; Assert.AreEqual(functionResult, publishedResult); }
public void NullContextThrowsValidationException() { var functionsManager = new FunctionsManager("component", "statemachine"); var exception = Assert.ThrowsAsync <ValidationException>(() => functionsManager. AddTaskAsync(new object(), new object(), new object(), null, new object(), "function")); Assert.IsTrue(exception.Message.Contains("Context"), "Exception message should show where is the problem"); }
public async Task AddTaskAsyncShouldReturnErrorResultIfTimeout() { FunctionsFactory.Instance.Configuration.TimeoutInMillis = 1; var functionsManager = new FunctionsManager("component", "statemachine"); var xcEvent = new object(); var publicMember = new object(); var internalMember = new object(); var context = new object(); var sender = Substitute.For <ISender>(); var publishedResult = await functionsManager.AddTaskAsync(xcEvent, publicMember, internalMember, context, sender, "function"); Assert.IsTrue(publishedResult.IsError); Assert.IsTrue(publishedResult.ErrorMessage.Contains("Timeout")); FunctionsFactory.Instance.Configuration.TimeoutInMillis = null; }