Esempio n. 1
0
        public static void GetDependencies_GivenNullOrWhiteSpaceExpression_ThrowsArgumentsNullException(string expression)
        {
            var        provider   = new SqlServerDependencyProvider();
            Identifier objectName = "test";

            Assert.That(() => provider.GetDependencies(objectName, expression), Throws.ArgumentNullException);
        }
Esempio n. 2
0
        public static void GetDependencies_GivenExpressionWithSameObjectAsFunction_ReturnsEmptyCollection()
        {
            var          provider   = new SqlServerDependencyProvider();
            Identifier   objectName = "test";
            const string expression = "select test(1)";

            var dependencies = provider.GetDependencies(objectName, expression);

            Assert.That(dependencies, Is.Empty);
        }
Esempio n. 3
0
        public static void GetDependencies_GivenExpressionPointingToOtherColumns_ReturnsColumnNames()
        {
            var          provider   = new SqlServerDependencyProvider();
            Identifier   objectName = "test";
            const string expression = "([first_name] + ' ' + [last_name])";

            var dependencies  = provider.GetDependencies(objectName, expression);
            var expectedNames = new[] { new Identifier("first_name"), new Identifier("last_name") };

            Assert.That(dependencies, Is.EqualTo(expectedNames));
        }
Esempio n. 4
0
        public static void GetDependencies_GivenExpressionPointingToOtherFunction_ReturnsOtherFunction()
        {
            var          provider   = new SqlServerDependencyProvider();
            Identifier   objectName = "test";
            const string expression = "select other_function(1)";

            var dependencies = provider.GetDependencies(objectName, expression);
            var dependency   = dependencies.Single();

            Assert.That(dependency.LocalName, Is.EqualTo("other_function"));
        }
Esempio n. 5
0
        public static void GetDependencies_GivenExpressionForViewPointingToTableAndFunction_ReturnsColumnsTablesAndFunctions()
        {
            var          provider   = new SqlServerDependencyProvider();
            Identifier   objectName = "test_view";
            const string expression = @"
CREATE VIEW [test_view] AS
SELECT 'test' AS FIRST_COL, 1 AS SECOND_COL
FROM FIRST_TABLE
UNION
SELECT * from client.FunctionName('test')
";

            var dependencies  = provider.GetDependencies(objectName, expression);
            var expectedNames = new[]
            {
                new Identifier("FIRST_COL"),
                new Identifier("SECOND_COL"),
                new Identifier("FIRST_TABLE"),
                new Identifier("client", "FunctionName")
            };

            Assert.That(dependencies, Is.EqualTo(expectedNames));
        }
Esempio n. 6
0
        public static void GetDependencies_GivenNullObjectName_ThrowsArgumentsNullException()
        {
            var provider = new SqlServerDependencyProvider();

            Assert.That(() => provider.GetDependencies(null, "test"), Throws.ArgumentNullException);
        }