Пример #1
0
        public async Task GetWritableAccessorAsync_GivenValidAccessorRequest_ShouldReturnAccessor()
        {
            var mockUrlProvider = new Mock <IInputObjectUrlProvider>();
            var mockSigner      = new Mock <ISigner <ObjectUrl> >();

            var objectUrlAccessorProvider = new InputObjectUrlAccessorProvider(mockUrlProvider.Object, mockSigner.Object);

            var accessorRequest = new InputObjectAccessorRequest
            {
                ExecutionMetadata = new ExecutionRequest {
                    ExecutionId = Guid.NewGuid().ToString()
                },
                ObjectMetadata = new ExtensionInputObject {
                    Name = "InputObjectA"
                }
            };

            var objectUrl = new ObjectUrl
            {
                Url        = "http://test.com/some-object",
                HttpMethod = HttpMethod.Put.Method
            };

            var objectUrlJson = JObject.FromObject(objectUrl);

            mockUrlProvider.Setup(up => up.GetWritableUrlAsync(It.Is <ObjectUrlRequest>(
                                                                   ur => ur.ExecutionMetadata.ExecutionId == accessorRequest.ExecutionMetadata.ExecutionId &&
                                                                   ur.ObjectName == accessorRequest.ObjectMetadata.Name)))
            .Returns(Task.FromResult(objectUrl));

            var accessor = await objectUrlAccessorProvider.GetWritableAccessorAsync(accessorRequest);

            accessor.Should().NotBeNull();
            accessor.Should().BeEquivalentTo(objectUrlJson);
        }
Пример #2
0
        public void GetWritableAccessorAsync_GivenNullAccessorRequest_ShouldThrowException()
        {
            var mockUrlProvider = new Mock <IInputObjectUrlProvider>();
            var mockSigner      = new Mock <ISigner <ObjectUrl> >();

            var objectUrlAccessorProvider = new InputObjectUrlAccessorProvider(mockUrlProvider.Object, mockSigner.Object);

            Func <Task> act = async() => await objectUrlAccessorProvider.GetWritableAccessorAsync(null);

            act.Should().Throw <ArgumentNullException>();
        }