2020-02-11 00:30:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-03-26 04:25:48 +00:00
|
|
|
|
using Xunit;
|
2020-02-11 00:30:38 +00:00
|
|
|
|
|
2020-03-26 04:25:48 +00:00
|
|
|
|
namespace Wabbajack.Common.Test
|
2020-02-10 23:25:24 +00:00
|
|
|
|
{
|
|
|
|
|
public class EncryptedDataTests
|
|
|
|
|
{
|
2020-02-11 00:30:38 +00:00
|
|
|
|
|
2020-03-26 04:25:48 +00:00
|
|
|
|
[Fact]
|
2020-02-11 00:30:38 +00:00
|
|
|
|
public async Task CanDetectNewEncryptedData()
|
|
|
|
|
{
|
2020-05-25 16:24:16 +00:00
|
|
|
|
var testString = Guid.NewGuid().ToString();
|
2020-02-11 00:30:38 +00:00
|
|
|
|
var data = new ConcurrentBag<string>();
|
2020-05-25 16:24:16 +00:00
|
|
|
|
var events = Utils.HaveEncryptedJsonObservable(testString).Subscribe(e =>
|
2020-02-11 00:30:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (e)
|
2020-05-25 16:24:16 +00:00
|
|
|
|
data.Add(testString);
|
2020-02-11 00:30:38 +00:00
|
|
|
|
else
|
|
|
|
|
data.Clear();
|
|
|
|
|
});
|
|
|
|
|
|
2020-05-25 16:24:16 +00:00
|
|
|
|
await testString.ToEcryptedJson(testString);
|
2020-02-11 00:30:38 +00:00
|
|
|
|
await Task.Delay(100);
|
|
|
|
|
|
2020-05-25 16:24:16 +00:00
|
|
|
|
Assert.Contains(testString, data);
|
2020-02-11 00:30:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-02-10 23:25:24 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|