Beispiel #1
0
            public void FindsDocumentInChildOfParentContext()
            {
                // Given
                TestDocument a  = new TestDocument();
                TestDocument b  = new TestDocument();
                TestDocument c  = new TestDocument();
                TestDocument d  = new TestDocument();
                TestDocument e  = new TestDocument();
                TestDocument e1 = new TestDocument();
                TestDocument e2 = new TestDocument();
                TestDocument e3 = new TestDocument();

                e.Add(Keys.Children, new IDocument[] { e1, e2, e3 });
                TestDocument         f       = new TestDocument();
                TestExecutionContext parent  = new TestExecutionContext(d, e, f);
                TestExecutionContext context = new TestExecutionContext(a, b, c);

                context.Parent = parent;
                LazyDocumentMetadataValue value = new LazyDocumentMetadataValue(e2);

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBe(e2);
                IExecutionContext.Current.ShouldBe(context); // Sanity check
            }
Beispiel #2
0
            public void DoesNotThrowForNullOriginalDocument()
            {
                // Given
                TestExecutionContext      context = new TestExecutionContext();
                LazyDocumentMetadataValue value   = new LazyDocumentMetadataValue();

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBeNull();
            }
Beispiel #3
0
            public void FindsDocumentInInputs()
            {
                // Given
                TestDocument              a       = new TestDocument();
                TestDocument              b       = new TestDocument();
                TestDocument              c       = new TestDocument();
                TestExecutionContext      context = new TestExecutionContext(a, b, c);
                LazyDocumentMetadataValue value   = new LazyDocumentMetadataValue(b);

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBe(b);
            }
Beispiel #4
0
            public void ReturnsOriginalDocumentIfNotFound()
            {
                // Given
                TestDocument              a       = new TestDocument();
                TestDocument              b       = new TestDocument();
                TestDocument              c       = new TestDocument();
                TestDocument              d       = new TestDocument();
                TestExecutionContext      context = new TestExecutionContext(a, b, c);
                LazyDocumentMetadataValue value   = new LazyDocumentMetadataValue(d);

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBe(d);
            }
Beispiel #5
0
            public void FindsDocumentInChildren()
            {
                // Given
                TestDocument a  = new TestDocument();
                TestDocument b  = new TestDocument();
                TestDocument b1 = new TestDocument();
                TestDocument b2 = new TestDocument();
                TestDocument b3 = new TestDocument();

                b.Add(Keys.Children, new IDocument[] { b1, b2, b3 });
                TestDocument              c       = new TestDocument();
                TestExecutionContext      context = new TestExecutionContext(a, b, c);
                LazyDocumentMetadataValue value   = new LazyDocumentMetadataValue(b2);

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBe(b2);
            }
Beispiel #6
0
            public void FindsDocumentInParentContext()
            {
                // Given
                TestDocument         a       = new TestDocument();
                TestDocument         b       = new TestDocument();
                TestDocument         c       = new TestDocument();
                TestDocument         d       = new TestDocument();
                TestDocument         e       = new TestDocument();
                TestDocument         f       = new TestDocument();
                TestExecutionContext parent  = new TestExecutionContext(d, e, f);
                TestExecutionContext context = new TestExecutionContext(a, b, c);

                context.Parent = parent;
                LazyDocumentMetadataValue value = new LazyDocumentMetadataValue(e);

                // When
                object result = value.Get(null);

                // Then
                result.ShouldBe(e);
                IExecutionContext.Current.ShouldBe(context); // Sanity check
            }