コード例 #1
0
        public async Task GetProductInfo_Should_Return_OK()
        {
            var mockHttp = new MockHttpMessageHandler();

            var server = "http://localhost";
            var file   = "test-file";
            var user   = "******";
            var pass   = "******";

            mockHttp.When(HttpMethod.Post, $"{server}/fmi/data/v1/databases/{file}/sessions")
            .Respond("application/json", DataApiResponses.SuccessfulAuthentication());

            var productInfo = System.IO.File.ReadAllText("ResponseData\\ProductInfo.json");

            mockHttp.When($"{server}/fmi/data/v1/productinfo")
            .Respond("application/json", productInfo);

            var fdc = new FileMakerRestClient(mockHttp.ToHttpClient(), new ConnectionInfo {
                FmsUri = server, Database = file, Username = user, Password = pass
            });

            var response = await fdc.GetProductInformationAsync();

            Assert.NotNull(response);
            Assert.NotEmpty(response.Name);
        }
コード例 #2
0
ファイル: MetadataTests.cs プロジェクト: fuzzzerd/fmdata
        public async Task GetProductInfo_Should_Return_OK()
        {
            var mockHttp = new MockHttpMessageHandler();

            var server = "http://localhost";
            var file   = "test-file";

            var productInfo = System.IO.File.ReadAllText(Path.Combine("ResponseData", "ProductInfo.json"));

            mockHttp.When($"{server}/fmi/data/v1/productinfo")
            .Respond("application/json", productInfo);

            var fdc = new FileMakerRestClient(mockHttp.ToHttpClient(), new ConnectionInfo {
                FmsUri = server, Database = file
            });

            var response = await fdc.GetProductInformationAsync();

            Assert.NotNull(response);
            Assert.NotEmpty(response.Name);
        }