private async Task TestAssetAsync(object data)
        {
            var sessionId = 0;
            var checksum  = Checksum.Create(WellKnownSynchronizationKind.Null, ImmutableArray.CreateRange(Guid.NewGuid().ToByteArray()));

            using var workspace = TestWorkspace.CreateCSharp(file: @"");

            using var remoteWorkspace = CreateRemoteWorkspace();

            var storage     = new SolutionAssetCache();
            var assetSource = new SimpleAssetSource(workspace.Services.GetService <ISerializerService>(), new Dictionary <Checksum, object>()
            {
                { checksum, data }
            });

            var provider = new AssetProvider(sessionId, storage, assetSource, remoteWorkspace.Services.GetService <ISerializerService>());
            var stored   = await provider.GetAssetAsync <object>(checksum, CancellationToken.None);

            Assert.Equal(data, stored);

            var stored2 = await provider.GetAssetsAsync <object>(new[] { checksum }, CancellationToken.None);

            Assert.Equal(1, stored2.Count);

            Assert.Equal(checksum, stored2[0].Item1);
            Assert.Equal(data, stored2[0].Item2);
        }
Esempio n. 2
0
        public async Task TestAssets()
        {
            var sessionId = 0;
            var checksum  = Checksum.Create(WellKnownSynchronizationKind.Null, ImmutableArray.CreateRange(Guid.NewGuid().ToByteArray()));
            var data      = new object();

            var storage = new AssetStorage();

            _ = new SimpleAssetSource(storage, new Dictionary <Checksum, object>()
            {
                { checksum, data }
            });

            var provider = new AssetProvider(sessionId, storage, new RemoteWorkspace().Services.GetService <ISerializerService>());
            var stored   = await provider.GetAssetAsync <object>(checksum, CancellationToken.None);

            Assert.Equal(data, stored);

            var stored2 = await provider.GetAssetsAsync <object>(new[] { checksum }, CancellationToken.None);

            Assert.Equal(1, stored2.Count);

            Assert.Equal(checksum, stored2[0].Item1);
            Assert.Equal(data, stored2[0].Item2);
        }