public static void ColumnComments_PropertyGetWhenCtorGivenDictionaryWithValues_ContainsExpectedValues()
        {
            var columnNames = new[]
            {
                new Identifier("test_column_1"),
                new Identifier("test_column_2"),
                new Identifier("test_column_3")
            };
            var columnComments = new Dictionary <Identifier, Option <string> >
            {
                [columnNames[0]] = Option <string> .None,
                [columnNames[1]] = Option <string> .Some("test comment for second column"),
                [columnNames[2]] = Option <string> .Some("test comment for third column")
            };

            var comments = new DatabaseViewComments("test_view", Option <string> .None, columnComments);

            var propColumnComments = comments.ColumnComments;

            Assert.Multiple(() =>
            {
                Assert.That(columnComments.Keys, Is.EqualTo(propColumnComments.Keys));

                Assert.That(columnComments["test_column_1"].IsNone, Is.EqualTo(propColumnComments["test_column_1"].IsNone));
                Assert.That(columnComments["test_column_2"].IsNone, Is.EqualTo(propColumnComments["test_column_2"].IsNone));
                Assert.That(columnComments["test_column_3"].IsNone, Is.EqualTo(propColumnComments["test_column_3"].IsNone));

                Assert.That(columnComments["test_column_2"].UnwrapSome(), Is.EqualTo(propColumnComments["test_column_2"].UnwrapSome()));
                Assert.That(columnComments["test_column_3"].UnwrapSome(), Is.EqualTo(propColumnComments["test_column_3"].UnwrapSome()));
            });
        }
Ejemplo n.º 2
0
        public async Task Generate_GivenMultiLineViewWithViewAndColumnComments_GeneratesExpectedOutput()
        {
            const string viewComment   = @"This is a test view comment for Poco.

This is a second line for it.";
            const string columnComment = @"This is a test column comment for Poco.

This is a second line for it.";

            var view = await GetView("test_view_3").ConfigureAwait(false);

            var generator = ViewGenerator;

            var comment = new DatabaseViewComments("test_view_3",
                                                   Option <string> .Some(viewComment),
                                                   new Dictionary <Identifier, Option <string> > {
                ["test_column_1"] = Option <string> .Some(columnComment)
            }
                                                   );
            var result = generator.Generate(view, comment);

            var expected = TestView3MultiLineOutput;

            Assert.That(result, Is.EqualTo(expected).Using(LineEndingInvariantStringComparer.Ordinal));
        }
        public static void ViewName_PropertyGet_EqualsCtorArg()
        {
            Identifier viewName = "test_view";
            var        comments = new DatabaseViewComments(viewName, Option <string> .None, Empty.CommentLookup);

            Assert.That(comments.ViewName, Is.EqualTo(viewName));
        }
        public static void Comment_PropertyGetWhenCtorGivenValidCommentValue_MatchesCommentValue()
        {
            const string commentText = "this is a test comment";
            var          commentArg  = Option <string> .Some(commentText);

            var comments = new DatabaseViewComments("test_view", commentArg, Empty.CommentLookup);

            Assert.That(comments.Comment.UnwrapSome(), Is.EqualTo(commentText));
        }
        public static void ColumnComments_PropertyGetWhenCtorGivenDictionaryWithValues_MatchesKeys()
        {
            var columnNames = new[]
            {
                new Identifier("test_column_1"),
                new Identifier("test_column_2"),
                new Identifier("test_column_3")
            };
            var columnComments = new Dictionary <Identifier, Option <string> >
            {
                [columnNames[0]] = Option <string> .None,
                [columnNames[1]] = Option <string> .None,
                [columnNames[2]] = Option <string> .None
            };

            var comments           = new DatabaseViewComments("test_view", Option <string> .None, columnComments);
            var propColumnComments = comments.ColumnComments;

            Assert.That(columnComments.Keys, Is.EqualTo(propColumnComments.Keys));
        }
        public static void ColumnComments_PropertyGetWhenCtorGivenEmptyDictionary_IsEmpty()
        {
            var comments = new DatabaseViewComments("test_view", Option <string> .None, Empty.CommentLookup);

            Assert.That(comments.ColumnComments, Is.Empty);
        }
        public static void Comment_PropertyGetWhenCtorGivenNone_IsNone()
        {
            var comments = new DatabaseViewComments("test_view", Option <string> .None, Empty.CommentLookup);

            Assert.That(comments.Comment, OptionIs.None);
        }