示例#1
0
        public async void TestIntegrate()
        {
            await FileService.TemporarilyUpload(Configuration.LocalIntegrateRevitFilePaths, async files =>
            {
                Assert.NotNull(files);
                Assert.True(files.Length > 1);
                Assert.True(files.All(file => file.FileId.HasValue));

                var translates = await Task.WhenAll(files.Select(file => TranslateService.EnsureTranslated(file)));

                var request = new FileIntegrateRequest
                {
                    Sources = translates
                              .Select(translate =>
                                      new IntegrateSource
                    {
                        FileId = translate.FileId
                    }).ToArray()
                };
                Output.WriteLine(JsonSerializer.Serialize(request));
                var integrate = await IntegrateService.CreateIntegrate(new CreateIntegrateParameter(request));
                Assert.NotNull(integrate);
                Assert.NotNull(integrate.IntegrateId);

                integrate = await IntegrateService.LookupIntegrate(new LookupIntegrateParameter(integrate.IntegrateId.Value));
                Assert.NotNull(integrate);
                Assert.NotNull(integrate.IntegrateId);

                var integrates = await IntegrateService.ListFileIntegrateDetails(
                    new ListFileIntegrateDetailsParameter(
                        new IntegrateQueryRequest
                {
                    EndDate = DateTime.Now + TimeSpan.FromDays(1)
                }));
                Assert.NotNull(integrates);
                Assert.True(integrates.List.Length > 0);
                Assert.Contains(integrate.IntegrateId, integrates.List.Select(i => i.IntegrateId));

                await IntegrateService.DeleteIntegrate(new DeleteIntegrateParameter(integrate.IntegrateId.Value));

                integrate = await IntegrateService.LookupIntegrate(new LookupIntegrateParameter(integrate.IntegrateId.Value));
                Assert.Null(integrate);
            });
        }