Esempio n. 1
0
    // ////////////////////////////////////////////////////////////////////////////////////////////
    // CRUD methods

    public async Task <BlockChainModel?> Get(DocumentId documentId, CancellationToken token)
    {
        Document?document = await _artifactClient.Get(documentId.WithContainer(_container), token);

        if (document == null)
        {
            return(null);
        }

        BlockChainModel model = document.DeserializeData <BlockChainModel>();

        return(model);
    }
Esempio n. 2
0
    public async Task <BankAccount?> Get(DocumentId documentId, CancellationToken token)
    {
        _logger.LogInformation($"Getting documentId={documentId}");
        documentId = documentId.WithContainer(_container);

        Document?document = await _artifactClient.Get(documentId, token);

        if (document == null)
        {
            return(null);
        }

        return(document.DeserializeData <BankAccount>());
    }
Esempio n. 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();
        }
Esempio n. 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();
        }