Esempio n. 1
0
        public void Constructor_IfProfileAndRegionAndKeysArguments_RegistersProfileAndInitializesClient(
            string profileName, string regionName, string accessKey, string secretKey)
        {
            var profileRegistrarMock = new Mock <IProfileRegistrar>(MockBehavior.Strict);

            profileRegistrarMock.Setup(x =>
                                       x.RegisterProfile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));
            var clientFactoryMock = new Mock <ISqsClientFactory>(MockBehavior.Strict);

            clientFactoryMock
            .Setup(x => x.CreateClient(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => null);

            var aws = new AwsSqs(clientFactoryMock.Object, profileRegistrarMock.Object, profileName, regionName, accessKey, secretKey);

            profileRegistrarMock.Verify(
                x => x.RegisterProfile(
                    It.Is <string>(arg => arg == profileName),
                    It.Is <string>(arg => arg == accessKey),
                    It.Is <string>(arg => arg == secretKey)),
                Times.Once);
            clientFactoryMock.Verify(
                x => x.CreateClient(It.Is <string>(arg => arg == profileName), It.Is <string>(arg => arg == regionName)),
                Times.Once);
        }
Esempio n. 2
0
 public void SetupState()
 {
     configuration = ConfigurationHelper.GetConfiguration();
     sqs           = CreateSqs();
     if (!runTests)
     {
         Assert.Ignore("The SQS tests are disabled by default because it is a paid service. Set 'runTests' field to true to run the tests.");
     }
 }
Esempio n. 3
0
        public void Constructor_IfProfileAndRegionArguments_InitializesClient(string profileName, string regionName)
        {
            var clientFactoryMock = new Mock <ISqsClientFactory>(MockBehavior.Strict);

            clientFactoryMock
            .Setup(x => x.CreateClient(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => null);

            var aws = new AwsSqs(clientFactoryMock.Object, profileName, regionName);

            clientFactoryMock.Verify(
                x => x.CreateClient(It.Is <string>(arg => arg == profileName), It.Is <string>(arg => arg == regionName)),
                Times.Once);
        }
Esempio n. 4
0
        public async Task SendMessageAsync_(string queueUrl, string messageBody)
        {
            var amazonSqsMock = new Mock <IAmazonSQS>(MockBehavior.Strict);

            amazonSqsMock
            .Setup(x => x.SendMessageAsync(It.IsAny <SendMessageRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((SendMessageResponse)null);
            var clientFactoryMock = new Mock <ISqsClientFactory>(MockBehavior.Strict);

            clientFactoryMock
            .Setup(x => x.CreateClient(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => amazonSqsMock.Object);
            var aws = new AwsSqs(clientFactoryMock.Object, It.IsAny <string>(), It.IsAny <string>());

            var result = await aws.SendMessageAsync(queueUrl, messageBody);

            amazonSqsMock.Verify(
                x =>
                x.SendMessageAsync(
                    It.Is <SendMessageRequest>(arg => arg.QueueUrl == queueUrl && arg.MessageBody == messageBody),
                    It.Is <CancellationToken>(arg => arg == default)), Times.Once);
        }