Exemple #1
0
    public async Task Set(DocumentId documentId, BlockChainModel blockChain, CancellationToken token)
    {
        Document document = new DocumentBuilder()
                            .SetDocumentId(documentId.WithContainer(_container))
                            .SetData(blockChain)
                            .Build();

        await _artifactClient.Set(document, token);
    }
Exemple #2
0
    public async Task Set(BankAccount entry, CancellationToken token)
    {
        _logger.LogInformation($"Set documentId={entry.AccountId}");

        DocumentId documentId = (DocumentId)entry.AccountId;

        documentId = documentId.WithContainer(_container);

        Document document = new DocumentBuilder()
                            .SetDocumentId(documentId)
                            .SetData(entry)
                            .Build();

        await _artifactClient.Set(document, token);
    }
Exemple #3
0
        public async Task GivenRecord_WhenRoundTrip_ShouldMatch()
        {
            ArtifactClient client = TestApplication.GetArtifactClient();

            var        payload    = new Payload("name1", "value1");
            DocumentId documentId = new DocumentId("contract:test/testing/payload.json");

            Document document = new DocumentBuilder()
                                .SetDocumentId(documentId)
                                .SetData(payload)
                                .Build()
                                .Verify();

            await client.Set(document);

            Document?readDocument = await client.Get(documentId);

            readDocument.Should().NotBeNull();
            readDocument !.Verify();

            (document == readDocument).Should().BeTrue();

            Payload?readPayload = readDocument !.DeserializeData <Payload>();

            readPayload.Should().NotBeNull();
            (payload == readPayload).Should().BeTrue();

            var search = new QueryParameter {
                Container = "contract", Filter = "test/testing"
            };

            BatchSet <DatalakePathItem> searchList = await client.Search(search).ReadNext();

            searchList.Should().NotBeNull();
            searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeTrue();

            (await client.Delete(documentId)).Should().BeTrue();

            searchList = await client.Search(search).ReadNext();

            searchList.Should().NotBeNull();
            searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeFalse();
        }
Exemple #4
0
        public async Task GivenData_WhenRoundTrip_ShouldMatch(string id)
        {
            ArtifactClient client = TestApplication.GetArtifactClient();

            const string payload    = "This is a test";
            DocumentId   documentId = new DocumentId(id);

            Document document = new DocumentBuilder()
                                .SetDocumentId(documentId)
                                .SetData(payload)
                                .Build()
                                .Verify();

            await client.Set(document);

            Document?readPayload = await client.Get(documentId);

            readPayload.Should().NotBeNull();
            readPayload !.Verify();

            (document == readPayload).Should().BeTrue();

            string?payloadText = readPayload !.DeserializeData <string>();

            payloadText.Should().Be(payload);

            var search = new QueryParameter {
                Container = "contract", Recursive = true
            };

            BatchSet <DatalakePathItem> searchList = await client.Search(search).ReadNext();

            searchList.Should().NotBeNull();
            searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeTrue();

            (await client.Delete(documentId)).Should().BeTrue();

            searchList = await client.Search(search).ReadNext();

            searchList.Should().NotBeNull();
            searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeFalse();
        }