Esempio n. 1
0
        public async void GetCollectorVersions_Unfiltered_Succeeds()
        {
            var collectorVersions = await PortalClient
                                    .GetAllCollectorVersionsAsync()
                                    .ConfigureAwait(false);

            Assert.NotNull(collectorVersions);
            Assert.NotEmpty(collectorVersions);
            Assert.All(collectorVersions, collectorVersion => Assert.NotEqual(0, collectorVersion.MajorVersion));
        }
Esempio n. 2
0
        public async void GetCollectorVersions_FilteredMandatory_Succeeds()
        {
            var collectorVersions = await PortalClient
                                    .GetAllCollectorVersionsAsync(new Filter <CollectorVersion>
            {
                FilterItems = new List <FilterItem <CollectorVersion> >
                {
                    new Eq <CollectorVersion>(nameof(CollectorVersion.Mandatory), true)
                }
            })
                                    .ConfigureAwait(false);

            Assert.NotNull(collectorVersions);
            Assert.NotEmpty(collectorVersions);
            Assert.All(collectorVersions, collectorVersion => Assert.True(collectorVersion.IsStable));
        }
Esempio n. 3
0
        public async void CreateCollectorDownloadAndDelete()
        {
            // Determine the latest supported version
            var collectorVersionInts = (await PortalClient.GetAllCollectorVersionsAsync(
                                            new Filter <CollectorVersion>
            {
                FilterItems = new List <FilterItem <CollectorVersion> >
                {
                    new Eq <CollectorVersion>(nameof(CollectorVersion.IsStable), true),
                }
            }
                                            ).ConfigureAwait(false))
                                       .Select(cv => (cv.MajorVersion * 1000) + cv.MinorVersion)
                                       .OrderByDescending(v => v)
                                       .ToList();

            Assert.NotNull(collectorVersionInts);
            Assert.NotEmpty(collectorVersionInts);

            var collectorVersionInt = collectorVersionInts[0];

            // Create the collector
            var collector = await PortalClient.CreateAsync(new CollectorCreationDto { Description = "UNIT TEST" }).ConfigureAwait(false);

            var tempFileInfo = new FileInfo(Path.GetTempPath() + Guid.NewGuid().ToString());

            try
            {
                await PortalClient.DownloadCollector(
                    collector.Id,
                    tempFileInfo,
                    CollectorPlatformAndArchitecture.Win64,
                    CollectorDownloadType.Bootstrap,
                    CollectorSize.Medium,
                    collectorVersionInt).ConfigureAwait(false);
            }
            finally
            {
                // No need to do this as the collector has not been registered
                // await DefaultPortalClient.DeleteAsync(collector).ConfigureAwait(false);
                tempFileInfo.Delete();

                // Remove the collector from the API
                await PortalClient.DeleteAsync(collector).ConfigureAwait(false);
            }
        }