public LambdaServiceTest()
 {
     _testObject = new LambdaService(_env.Object,
                                     _responseWrapper.Object,
                                     _dynamoDbContextWrapper.Object,
                                     _apiGatewayManagementApi.Object,
                                     _amazonIotData.Object);
 }
        public async void SavesMessage()
        {
            // Invoke the lambda function and confirm the string was upper cased.
            var dynamoDbContext = new Mock <IDynamoDBContext>();

            var testObject = new LambdaService(new EnvironmentWrapper(), dynamoDbContext.Object);
            var context    = new TestLambdaContext();

            var message = new Message();
            await testObject.IngestMessage(message, context);

            dynamoDbContext.Verify(x => x.SaveAsync(message, It.IsAny <CancellationToken>()));
        }
        public LambdaTestDispatcher(TContract instance) : base(new JsonProxySerializer())
        {
            _instance = instance;

            LambdaServiceBuilder serviceBuilder = new LambdaServiceBuilder()
                                                  .ConfigureDependencies(x =>
            {
                x.AddSingleton(typeof(TContract), instance);
            })
                                                  .AddProxyService <TContract>();

            _serviceMap = new ServiceMap();
            _serviceMap.RegisterContract <TContract>();

            _lambdaService = serviceBuilder.Build();
        }
Пример #4
0
        public void GetVersion_ReturnsVersionFromEnv()
        {
            var expectedVersion  = "abc";
            var expectedResponse = new APIGatewayProxyResponse();

            var env             = new Mock <IEnvironmentWrapper>();
            var responseWrapper = new Mock <IResponseWrapper>();

            env.Setup(x => x.GetEnvironmentVariable("Version")).Returns(expectedVersion);
            responseWrapper.Setup(x => x.Success(It.Is <VersionInfo>(v => v.Version == expectedVersion)))
            .Returns(expectedResponse);

            // Invoke the lambda function and confirm the string was upper cased.
            var testObject = new LambdaService(env.Object, responseWrapper.Object);
            var context    = new TestLambdaContext();
            var result     = testObject.GetVersion(null, context);

            Assert.Equal(expectedResponse, result);
        }
Пример #5
0
        public Function()
        {
            //Split for readability
            LambdaServiceBuilder serviceBuilder = new LambdaServiceBuilder();

            //Configure any dependancies
            serviceBuilder = serviceBuilder
                             .ConfigureDependencies(x =>
            {
                x.AddSingleton <IAdditionService, AdditionService>();
                x.AddSingleton <ISubtractionService, SubtractionService>();
            });

            //Add the proxy service to wire up the contracts
            //Only services that have been added will be exposed
            serviceBuilder = serviceBuilder
                             .AddProxyService <IAdditionService>()
                             .AddProxyService <ISubtractionService>();

            _service = serviceBuilder.Build();
        }
 public LambdaServiceTest()
 {
     _testObject = new LambdaService(_dynamoDbContextWrapper.Object);
 }