public async Task TestProcessEntities()
        {
            sourceDataRepository
            .ReadAllRecursively("folder1")
            .Returns(new[]
            {
                new SourceEntity
                {
                    Folder   = "folder1",
                    Id       = "id1",
                    Name     = "Name1",
                    Password = "******",
                    Created  = "2020.01.01"
                },
                new SourceEntity
                {
                    Folder   = "folder1",
                    Id       = "id2",
                    Name     = "Name2",
                    Password = "******",
                    Created  = "2020.01.02"
                }
            });

            await entityProcessor.ProcessFolder("folder1");

            await targetDataRepository
            .Received()
            .Write(Arg.Is(new TargetEntity
            {
                Folder       = "folder1",
                Id           = "id1",
                Name         = "Name1",
                PasswordHash = "0b14d501a594442a01c6859541bcb3e8164d183d32937b851835442f69d5c94e",
                Created      = "2020.01.01"
            }));

            await targetDataRepository
            .Received()
            .Write(Arg.Is(new TargetEntity
            {
                Folder       = "folder1",
                Id           = "id2",
                Name         = "Name2",
                PasswordHash = "6cf615d5bcaac778352a8f1f3360d23f02f34ec182e259897fd6ce485d7870d4",
                Created      = "2020.01.02"
            }));
        }
Beispiel #2
0
        public async Task FunctionHandler(string folderName, ILambdaContext context)
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                         .Build();

            var accessKey = config["accessKey"];
            var secretKet = config["secretKey"];

            var s3RegionName       = Environment.GetEnvironmentVariable("S3_region");
            var dynamoDbRegionName = Environment.GetEnvironmentVariable("DynamoDB_region");
            var bucketName         = Environment.GetEnvironmentVariable("S3_bucket_name");
            var tableName          = Environment.GetEnvironmentVariable("DynamoDB_table_name");

            var s3Repository       = new S3Repository(accessKey, secretKet, s3RegionName, bucketName);
            var dynamoDbRepository = new DynamoDbRepository(accessKey, secretKet, dynamoDbRegionName, tableName);
            var entityProcessor    = new EntityProcessor(s3Repository, dynamoDbRepository);

            await entityProcessor.ProcessFolder(folderName);
        }