public async void TestNotExistGetDocumentAsync()
        {
            var targetFunction = "lambda:function";

            // setup
            DocumentTypeRegistry.RegisterDocumentType <BasicEmptyInterface>("empty-interface");

            var lambdaMock = new Mock <IAmazonLambda>();

            lambdaMock.Setup(l => l.InvokeAsync(
                                 It.IsAny <InvokeRequest>(),
                                 It.IsAny <CancellationToken>())
                             ).ReturnsAsync(
                new InvokeResponse()
            {
                Payload = new MemoryStream(Encoding.UTF8.GetBytes(
                                               @"{""type"":""empty-interface"",""doc"":null}"
                                               ))
            }
                );

            var client = new JsonballAwsClient(lambdaMock.Object, null);

            client.GetDocumentFunction = targetFunction;

            // performe test

            var doc = await client.GetDocumentAsync(null);

            Assert.Null(doc.Body);
            Assert.Equal <uint>(0, doc.Version);
        }
示例#2
0
        public void TestCustomDocumentType()
        {
            DocumentTypeRegistry.RegisterDocumentType <TestDocument>("person");

            var doc = JsonSerializer.Deserialize <Document>(
                "{\"name\": \"some-name\", \"version\": 1, \"type\": \"person\", \"doc\": {\"name\": \"firstname\", \"age\": 123}}"
                );

            Assert.Equal("person", doc.Type);
            Assert.Equal("some-name", doc.Name);
            Assert.Equal <uint>(1, doc.Version);

            var testDoc = (TestDocument)doc.Body;

            Assert.Equal("firstname", testDoc.Name);
            Assert.Equal(123, testDoc.Age);
        }