Пример #1
0
        public async Task CreateWithScript_RequiresScriptSet()
        {
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When(HttpMethod.Post, $"{server}/fmi/data/v1/databases/{file}/layouts/{layout}/records*")
            .WithPartialContent("fieldData")
            .WithPartialContent("script")     // ensure the body contains the script parameter we're sending
            .WithPartialContent("run_this_script")
            .Respond("application/json", DataApiResponses.SuccessfulCreate());

            IFileMakerApiClient fdc = GetDataClientWithMockedHandler(mockHttp);

            var req = new CreateRequest <User>()
            {
                Layout = "layout",
                Data   = new User {
                    Name = "test name"
                },
                Script = "run_this_script"
            };

            var response = await fdc.SendAsync(req);

            Assert.NotNull(response);
            Assert.Contains(response.Messages, r => r.Message == "OK");
        }
Пример #2
0
        public async Task CreateFromDictionaryStringString_ShouldReturnOK_FromSendAsync()
        {
            IFileMakerApiClient fdc = GetDataClientWithMockedHandler();

            var response = await fdc.SendAsync(reqWithLayout);

            Assert.NotNull(response);
            Assert.Contains(response.Messages, r => r.Message == "OK");
        }
Пример #3
0
        public async Task Create_WithoutLayout_ThrowsArgumentException_SendAsync()
        {
            IFileMakerApiClient fdc = GetDataClientWithMockedHandler();

            await Assert.ThrowsAsync <ArgumentException>(async() => await fdc.SendAsync(reqWithoutLayout));
        }