public void JoinsWithPackageRegistrationsTable()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.Contains("INNER JOIN [dbo].[PackageRegistrations] AS PR ON P.[PackageRegistrationKey] = PR.[Key]", queryString);
            }
            public void OnlyConsidersPackagesWithAvailableStatus()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.Contains($"WHERE P.[PackageStatusKey] = {(int)PackageStatus.Available}", queryString);
            }
            public void SelectsFromPackagesTable()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.Contains("FROM [dbo].[Packages] AS P", queryString);
            }
            public void OrdersByCursorColumnName_LastEdited()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByLastEdited(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.EndsWith($"ORDER BY P.[{cursor.ColumnName}]", queryString);
            }
            public void SelectsTopWithTies()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 10);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.StartsWith($"SELECT TOP {cursor.Top} WITH TIES", queryString);
            }
Esempio n. 6
0
            public void OrdersByCursorColumnName_Created()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.EndsWith($"ORDER BY P_EXT.[{cursor.ColumnName}], P_EXT.[{Db2CatalogProjectionColumnNames.Key}]", queryString);
            }
Esempio n. 7
0
            public void JoinsWithPackageVulnerabilitiesTables()
            {
                // Arrange
                var cursor = Db2CatalogCursor.ByCreated(DateTime.UtcNow, 20);

                // Act
                var queryString = GalleryDatabaseQueryService.BuildDb2CatalogSqlQuery(cursor);

                // Assert
                Assert.Contains("LEFT JOIN [dbo].[VulnerablePackageVersionRangePackages] AS VPVRP ON VPVRP.[Package_Key] = P_EXT.[Key]", queryString);
                Assert.Contains("LEFT JOIN [dbo].[VulnerablePackageVersionRanges] AS VPVR ON VPVR.[Key] = VPVRP.[VulnerablePackageVersionRange_Key]", queryString);
                Assert.Contains("LEFT JOIN [dbo].[PackageVulnerabilities] AS PV ON PV.[Key] = VPVR.[VulnerabilityKey]", queryString);
            }