Ejemplo n.º 1
0
        public async Task TestInsertAndDeleteNewFeaturesAsync()
        {
            var examplesDir = new DirectoryInfo(ExampleFeatures);

            var locking = GetLocking();

            foreach (var exampleFile in examplesDir.GetFiles())
            {
                var lokalId = new Guid(exampleFile.Name.Split('.')[0]);

                var existingFeature = await LockAndSaveFeatureByLokalIdAsync(lokalId, locking);

                if (FileHasFeatures(existingFeature))
                {
                    await DeleteByLokalIdAsync(existingFeature, lokalId, locking);
                }

                var insertXml = Wfs.CreateInsertTransaction(exampleFile.FullName, new List <Guid> {
                    lokalId
                });

                Console.WriteLine($"Executing Insert");

                var response = await Execute(locking, insertXml);

                Assert.IsTrue(response.Features_created > 0, "No features updated");

                var newFeature = await LockAndSaveFeatureByLokalIdAsync(lokalId, locking);

                await DeleteByLokalIdAsync(newFeature, lokalId, locking);
            }
        }
Ejemplo n.º 2
0
        public async Task TestInsertAndDeleteNewFeaturesAsync()
        {
            var xml = General.GetExampleFile("ArealressursGrense");

            var lokalId = Wfs.GetLokalId(xml);

            var locking = GetLocking();

            var existingFeature = await LockAndSaveFeatureByLokalIdAsync(lokalId, locking);

            if (FileHasFeatures(existingFeature))
            {
                await DeleteByLokalIdAsync(existingFeature, lokalId, locking);
            }

            var insertXml = Wfs.CreateInsertTransaction(xml, new List <Guid> {
                lokalId
            });

            Console.WriteLine($"Executing Insert");

            var response = await Execute(locking, insertXml);

            Assert.IsTrue(response.Features_created > 0, "No features updated");

            var newFeature = await LockAndSaveFeatureByLokalIdAsync(lokalId, locking);

            await DeleteByLokalIdAsync(newFeature, lokalId, locking);
        }
Ejemplo n.º 3
0
        private async Task DeleteByLokalIdAsync(string tempFile, List <Guid> lokalIds, Locking locking)
        {
            string deleteXmlPath = Wfs.CreateDeleteTransaction(tempFile, lokalIds);

            Console.WriteLine($"Executing Delete");

            var response = await Execute(locking, deleteXmlPath);

            Assert.IsTrue(response.Features_erased > 0, $"Feature with lokalIds ({string.Join(',', lokalIds)}) not deleted");
        }
Ejemplo n.º 4
0
        internal static XElement GetExampleFile(string fileName)
        {
            var examplesDir = new DirectoryInfo(ExampleFeatures);

            foreach (var exampleFile in examplesDir.GetFiles($"{fileName}.*"))
            {
                var xml = XElement.Load(exampleFile.FullName);

                Wfs.SetActiveNamespaceConstants(xml);

                return(xml);
            }

            throw new FileNotFoundException($"File with name {fileName} not found");
        }
Ejemplo n.º 5
0
        private async Task ReplaceByLokalIdAsync(Guid datasetId, Guid lokalId)
        {
            var locking = GetLocking();

            var tempFile = await LockAndSaveFeatureByLokalIdAsync(lokalId, locking);

            var datasetLocks = await Client.GetDatasetLocksAsync(clientString, datasetId, locking);

            Assert.IsTrue(datasetLocks?.Count() > 0, $"No dataset found for datasetId {datasetId}");

            var lockedLokalIds = datasetLocks.SelectMany(l => l?.Features?.Select(f => f.Lokalid))?.ToList();

            Assert.IsTrue(lockedLokalIds != null && lockedLokalIds.Count > 0, $"No features locked for datasetId {datasetId} and lokalId {lokalId}");

            var wfsReplaceFile = Wfs.CreateReplaceTransaction(tempFile, lockedLokalIds);

            Console.WriteLine($"Executing Replace");

            var response = await Execute(locking, wfsReplaceFile);

            Assert.IsTrue(response.Features_replaced > 0, "No features updated");
        }