ExecuteAsync() public method

Executes the SfRequest asynchronously.
When source or sessionId is null. When sessionId has not a length of 32.
public ExecuteAsync ( IRequestSource source, string sessionId, SF action, IEnumerable args = null ) : Task
source IRequestSource The addressed request source, which should be an instance of type in usual cases.
sessionId string A valid session ID, with the length of 32. is used for logging in.
action SF The action which shall be executed. See which start with "Act".
args IEnumerable Additional arguments like e.g. the search string for searches or the user credentials for logging in.
return Task
Esempio n. 1
0
        public void ExecuteAsyncThrowsExceptionIfSourceIsNull()
        {
            // Arrange
            var sut = new SfRequest();
            Func<Task> a = async () => await sut.ExecuteAsync(null, null, SF.ActAccountCreate);

            // Act / Assert
            a.ShouldThrow<ArgumentNullException>().Where(e => e.ParamName == "source");
        }
Esempio n. 2
0
        public void ExecuteAsyncThrowsExceptionIfSessionIdIsNull()
        {
            // Arrange
            var sourceMock = new Mock<IRequestSource>();
            var sut = new SfRequest();
            Func<Task> a = async () => await sut.ExecuteAsync(sourceMock.Object, null, SF.ActAccountCreate);

            // Act / Assert
            a.ShouldThrow<ArgumentNullException>().Where(e => e.ParamName == "sessionId");
        }
Esempio n. 3
0
        public void ExecuteAsyncThrowsExceptionIfSessionIdHasInvalidLength()
        {
            // Arrange
            var sourceMock = new Mock<IRequestSource>();
            var sut = new SfRequest();
            Func<Task> a =
                async () =>
                await sut.ExecuteAsync(sourceMock.Object, TestConstants.InvalidSessionId, SF.ActAccountCreate);

            // Act / Assert
            a.ShouldThrow<ArgumentException>()
             .Where(e => e.ParamName == "sessionId" && e.Message.StartsWith("sessionId must have a length of 32."));
        }
Esempio n. 4
0
        public async Task ExecuteAsyncReturnsISfResponseWithValidParameters()
        {
            // Arrange
            var sfResponseMock = new Mock<ISfResponse>();
            var sourceMock = new Mock<IRequestSource>();
            sourceMock.Setup(source => source.RequestAsync(It.IsAny<string>(),
                                                           It.IsAny<SF>(),
                                                           It.IsAny<IEnumerable<string>>()))
#pragma warning disable 1998
                      .Returns(async () => sfResponseMock.Object);
#pragma warning restore 1998
            var sut = new SfRequest();

            // Act
            var result = await sut.ExecuteAsync(sourceMock.Object, TestConstants.ValidSessionId, SF.ActAccountCreate);

            // Assert
            result.Should().NotBeNull();
        }
Esempio n. 5
0
        public async Task ExecuteAsyncCallsRequestAsyncMethodOfSource()
        {
            // Arrange
            var sourceMock = new Mock<IRequestSource>();
            sourceMock.Setup(source => source.RequestAsync(It.IsAny<string>(),
                                                           It.IsAny<SF>(),
                                                           It.IsAny<IEnumerable<string>>()))
#pragma warning disable 1998
                      .Returns(async () => null)
#pragma warning restore 1998
                      .Verifiable();

            var sut = new SfRequest();
            Func<Task> a =
                async () => await sut.ExecuteAsync(sourceMock.Object, TestConstants.ValidSessionId, SF.ActAccountCreate);

            // Act
            await a();

            // Assert
            sourceMock.Verify(
                source => source.RequestAsync(It.IsAny<string>(), It.IsAny<SF>(), It.IsAny<IEnumerable<string>>()),
                Times.Once());
        }