public async Task When_FileProcessing_Returns_Error_ErrorTransactionOutcome_Is_Signaled() { // Arrange RebuildOutcome actualOutcome = null; string actualBlobName = string.Empty; var expectedOutcome = new RebuildOutcome { Outcome = ProcessingOutcome.Error, RebuiltFileSas = string.Empty }; _mockContext.Setup(s => s.CallActivityAsync <string>( It.Is <string>(s => s == "FileProcessing_GetFileType"), It.IsAny <object>())) .ReturnsAsync("error"); _mockContext.Setup(s => s.CallActivityAsync <object>( It.Is <string>(s => s == "FileProcessing_SignalTransactionOutcome"), It.IsAny <object>())) .Callback <string, object>((s, obj) => { actualBlobName = (string)obj.GetType().GetField("Item1").GetValue(obj); actualOutcome = (RebuildOutcome)obj.GetType().GetField("Item2").GetValue(obj); }); // Act await _fileProcessingOrchestrator.RunOrchestrator(_mockContext.Object, _cloudBlobContainer, _mockLogger.Object); // Assert Assert.That(actualBlobName, Is.EqualTo(BlobName)); Assert.That(actualOutcome.Outcome, Is.EqualTo(expectedOutcome.Outcome)); Assert.That(actualOutcome.RebuiltFileSas, Is.EqualTo(expectedOutcome.RebuiltFileSas)); }
public async Task When_Hash_Is_Found_In_Cache_GetFileType_IsNot_Called() { // Arrange _mockContext.Setup(s => s.CallActivityAsync <OutcomeEntity>( It.Is <string>(s => s == "FileProcessing_GetEntityFromCache"), It.IsAny <object>())) .ReturnsAsync(new OutcomeEntity { FileType = "docx" }); // Act await _fileProcessingOrchestrator.RunOrchestrator(_mockContext.Object, _cloudBlobContainer, _mockLogger.Object); // Assert _mockContext.Verify(s => s.CallActivityAsync <string>( It.Is <string>(s => s == "FileProcessing_GetFileType"), It.IsAny <object>()), Times.Never); }