Exemplo n.º 1
0
 public async Task ProcessFolder(string folderName)
 {
     foreach (var sourceEntity in await sourceDataRepository.ReadAllRecursively(folderName))
     {
         await targetDataRepository.Write(ProcessEntity(sourceEntity));
     }
 }
        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"
            }));
        }