Пример #1
0
        public void GenerateGetQuery_NoPrimaryKey_Valid()
        {
            // Arrange
            var generator = new SqlQueryGenerator <HeapEntity>("dbo", "Users");

            // Act
            var query = generator.GenerateGetQuery();

            // Assert
            Assert.Equal("SELECT [dbo].[Users].[Username], [dbo].[Users].[Password] FROM [dbo].[Users] WHERE [dbo].[Users].[Username] = @Username AND [dbo].[Users].[Password] = @Password;", query);
        }
Пример #2
0
        public void GenerateGetQuery_CompositePrimaryKey_Valid()
        {
            // Arrange
            var generator = new SqlQueryGenerator <CompositePrimaryKeyEntity>("dbo", "Users");

            // Act
            var selectQuery = generator.GenerateGetQuery();

            // Assert
            Assert.Equal($"SELECT [dbo].[Users].[Username], [dbo].[Users].[Password], [dbo].[Users].[DateCreated] FROM [dbo].[Users] WHERE [dbo].[Users].[Username] = @Username AND [dbo].[Users].[Password] = @Password;", selectQuery);
        }
Пример #3
0
        public void GenerateGetQuery_CustomColumnNames_Valid()
        {
            // Arrange
            var generator = new SqlQueryGenerator <CustomColumnNamesEntity>("dbo", "Orders");

            // Act
            var selectQuery = generator.GenerateGetQuery();

            // Assert
            Assert.Equal($"SELECT [dbo].[Orders].[OrderId] AS [Id], [dbo].[Orders].[DateCreated] AS [Date] FROM [dbo].[Orders] WHERE [dbo].[Orders].[OrderId] = @Id;", selectQuery);
        }
Пример #4
0
        public void GenerateGetQuery_SinglePrimaryKey_Valid()
        {
            // Arrange
            var generator = new SqlQueryGenerator <SinglePrimaryKeyEntity>("dbo", "Users");

            // Act
            var selectQuery = generator.GenerateGetQuery();

            // Assert
            Assert.Equal($"SELECT [dbo].[Users].[Id], [dbo].[Users].[Username], [dbo].[Users].[Password] FROM [dbo].[Users] WHERE [dbo].[Users].[Id] = @Id;", selectQuery);
        }