Example #1
0
            public void ReturnsFalseForAmbiguousMatches()
            {
                // Given
                TestDocument a = new TestDocument
                {
                    { WebKeys.Xref, "12" }
                };
                TestDocument b = new TestDocument
                {
                    { WebKeys.Xref, "34" }
                };
                TestDocument c = new TestDocument
                {
                    { WebKeys.Xref, "12" }
                };
                TestExecutionContext context = new TestExecutionContext();

                context.Outputs.Dictionary.Add(
                    nameof(Content),
                    new IDocument[] { a, b, c }.ToImmutableArray());

                // When
                bool success = context.TryGetXrefDocument("12", out IDocument result, out string error);

                // Then
                success.ShouldBeFalse();
                result.ShouldBeNull();
                error.ShouldNotBeNullOrWhiteSpace();
            }
Example #2
0
            public void FindsXrefInChildDocuments()
            {
                // Given
                TestDocument a = new TestDocument
                {
                    { WebKeys.Xref, "12" }
                };
                TestDocument child = new TestDocument
                {
                    { WebKeys.Xref, "78" }
                };
                TestDocument b = new TestDocument
                {
                    { WebKeys.Xref, "34" },
                    { Keys.Children, new IDocument[] { child } }
                };
                TestDocument c = new TestDocument
                {
                    { WebKeys.Xref, "56" }
                };
                TestExecutionContext context = new TestExecutionContext();

                context.Outputs.Dictionary.Add(
                    nameof(Content),
                    new IDocument[] { a, b, c }.ToImmutableArray());

                // When
                bool success = context.TryGetXrefDocument("78", out IDocument result, out string error);

                // Then
                success.ShouldBeTrue();
                result.ShouldBe(child);
                error.ShouldBeNull();
            }
Example #3
0
            public void FindXrefIsCaseInsensitive()
            {
                // Given
                TestDocument a = new TestDocument
                {
                    { WebKeys.Xref, "fooBAR" }
                };
                TestExecutionContext context = new TestExecutionContext();

                context.Outputs.Dictionary.Add(
                    nameof(Content),
                    new IDocument[] { a }.ToImmutableArray());

                // When
                bool success = context.TryGetXrefDocument("FOObar", out IDocument result, out string error);

                // Then
                success.ShouldBeTrue();
                result.ShouldBe(a);
                error.ShouldBeNull();
            }
Example #4
0
            public void NullXrefDoesNotThrow()
            {
                // Given
                TestDocument a = new TestDocument
                {
                    { WebKeys.Xref, null }
                };
                TestExecutionContext context = new TestExecutionContext();

                context.Outputs.Dictionary.Add(
                    nameof(Content),
                    new IDocument[] { a }.ToImmutableArray());

                // When
                bool success = context.TryGetXrefDocument("fizzbuzz", out IDocument result, out string error);

                // Then
                success.ShouldBeFalse();
                result.ShouldBeNull();
                error.ShouldNotBeNullOrWhiteSpace();
            }