public void CodeSenseShouldReturnMaxStringLengthScriptFileMarkerErrorItemWhenScriptIsTooLong()
        {
            // SQL length of 300 characters
            string sqlLength_300 = $@"
                DECLARE @SSN CHAR(11) = '123-45-6789'
                DECLARE @BIRTHDAY DATE = '19990104'
                DECLARE @SALARY MONEY = '$30000'

                SELECT * FROM [dbo].[Patients]
                WHERE [N] = @SSN AND [B] = @BIRTHDAY AND [S] = @SALARY
                GO";

            // Repeat the SQL 1001 times to exceed length threshold
            string sql = string.Concat(Repeat(element: sqlLength_300, count: 1100));

            IList <ScriptFileMarker> result = SqlParameterizer.CodeSense(sql);
            string expectedMessage          = SR.ScriptTooLarge(maxChars: 300000, currentChars: sql.Length);

            Console.WriteLine(result[0].Message);

            Assert.NotEmpty(result);
            Assert.Equal(expected: 1, actual: result.Count);
            Assert.Equal(expected: ScriptFileMarkerLevel.Error, actual: result[0].Level);
            Assert.Equal(expected: expectedMessage, actual: result[0].Message);
        }
        public void CodeSenseShouldReturnEmptyListWhenGivenANullScript()
        {
            string sql = null;
            IList <ScriptFileMarker> result = SqlParameterizer.CodeSense(sql);

            Assert.NotNull(result);
            Assert.Empty(result);
        }
        public void CodeSenseShouldReturnEmptyListWhenGivenAParameterlessScript()
        {
            // SQL with no parameters
            string sql = $@"
                SELECT * FROM [dbo].[Patients]
                WHERE [N] = @SSN AND [B] = @BIRTHDAY AND [S] = @SALARY
                GO";

            IList <ScriptFileMarker> result = SqlParameterizer.CodeSense(sql);

            Assert.NotNull(result);
            Assert.Empty(result);
        }
        public void CodeSenseShouldReturnInformationalCodeSenseItemsForValidParameters()
        {
            const string ssn      = "795-73-9838";
            const string birthday = "19990104";
            const string salary   = "$30000";

            string sql = $@"
                DECLARE @SSN CHAR(11) = '{ssn}'
                DECLARE @BIRTHDAY DATE = '{birthday}'
                DECLARE @SALARY MONEY = '{salary}'

                SELECT * FROM [dbo].[Patients]
                WHERE [SSN] = @SSN AND [BIRTHDAY] = @BIRTHDAY AND [SALARY] = @SALARY";

            IList <ScriptFileMarker> result = SqlParameterizer.CodeSense(sql);

            Assert.NotEmpty(result);
            Assert.Equal(expected: 3, actual: result.Count);
            Assert.True(Enumerable.All(result, i => i.Level == ScriptFileMarkerLevel.Information));
        }