public async Task Error_Is_Returned_When_Issues_With_DetectingFileType()
            {
                // Arrange
                const string blobSas = "http://im-a-blob-sas";

                var durableActivityContext = new Mock <IDurableActivityContext>();
                var logger        = new Mock <ILogger>();
                var configuration = new Mock <IConfigurationSettings>();

                configuration.SetupGet(s => s.FiletypeDetectionKey).Returns("TestKey");
                configuration.SetupGet(s => s.FiletypeDetectionUrl).Returns("http://testrebuildurl");

                durableActivityContext.Setup(s => s.GetInput <string>())
                .Returns(blobSas);

                _httpTest.RespondWith(string.Empty, 500);

                var classToTest = new GetFileType(configuration.Object);

                // Act

                var outcome = await classToTest.Run(durableActivityContext.Object, logger.Object);

                // Assert
                Assert.That(outcome, Is.EqualTo("Error"));
            }
            public async Task FileTypeName_Is_Returned_When_Successfully_Detecting_FileType()
            {
                // Arrange
                const string blobSas          = "http://im-a-blob-sas";
                const string expectedFileType = "doc";

                var durableActivityContext = new Mock <IDurableActivityContext>();
                var logger        = new Mock <ILogger>();
                var configuration = new Mock <IConfigurationSettings>();

                configuration.SetupGet(s => s.FiletypeDetectionKey).Returns("TestKey");
                configuration.SetupGet(s => s.FiletypeDetectionUrl).Returns("http://testrebuildurl");

                durableActivityContext.Setup(s => s.GetInput <string>())
                .Returns(blobSas);

                _httpTest.RespondWithJson(new { FileTypeName = expectedFileType });

                var classToTest = new GetFileType(configuration.Object);

                // Act
                var outcome = await classToTest.Run(durableActivityContext.Object, logger.Object);

                // Assert
                Assert.That(outcome, Is.EqualTo(expectedFileType));
            }
示例#3
0
            public async Task FileTypeName_Is_Returned_When_Successfully_Detecting_FileType()
            {
                // Arrange
                const string expectedFileType = "doc";

                _httpTest.RespondWithJson(new { FileTypeName = expectedFileType });

                // Act
                var outcome = await _classUnderTest.Run(_mockContext.Object, _mockLogger.Object);

                // Assert
                Assert.That(outcome, Is.EqualTo(expectedFileType));

                _httpTest.ShouldHaveCalled(ApiUrl)
                .WithHeader("x-api-key", ApiKey)
                .Times(1);
            }