public async Task TestSftpFileStore_Context() { var dataStore = new ContextFactory().Create <ISftpDataContext>().Store; var tasks = Enumerable .Range(0, 3) .Select(i => Task.Run(() => { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); _output.WriteLine($"Starting {i}"); TestDataStore( dataStore, testKey, testValueA, testValueB); _output.WriteLine($"Finished {i}"); })); await Task.WhenAll(tasks); }
public void TestSftpFileStore_FromRoot() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new SftpFileStore( host: Host, username: Username, password: Password), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public async Task TestSftpFileStore_Concurrent() { int concurrentCount = 30; var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new SftpFileStore( host: Host, username: Username, password: Password, maxConcurrentConnections: $"{concurrentCount}"), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/another folder/moar_folder/{AccountId}", fileExtension: ".json"); var tasks = Enumerable .Range(0, concurrentCount) .Select(i => Task.Run(() => { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); _output.WriteLine($"Starting {i}"); TestDataStore( dataStore, testKey, testValueA, testValueB); _output.WriteLine($"Finished {i}"); })); await Task.WhenAll(tasks); }