Esempio n. 1
0
        public void GetFirstChild_WhenNoChildren_ShouldReturnNull()
        {
            // Arrange
            _contentLoaderMock
            .Setup(c => c.GetChildren <IContentData>(It.IsAny <ContentReference>()))
            .Returns(Enumerable.Empty <IContentData>());

            // Act
            var result = ContentLoaderExtensions.GetFirstChild <IContentData>(_contentLoaderMock.Object, null);

            // Assert
            Assert.Null(result);
        }
Esempio n. 2
0
        public void GetFirstChild_WhenOneChild_ShouldReturnThatChild()
        {
            // Arrange
            var child = new Mock <IContentData>().Object;

            _contentLoaderMock
            .Setup(c => c.GetChildren <IContentData>(It.IsAny <ContentReference>()))
            .Returns(new[] { child });

            // Act
            var result = ContentLoaderExtensions.GetFirstChild <IContentData>(_contentLoaderMock.Object, null);

            // Assert
            Assert.Same(child, result);
        }
        public void GetFirstChild_WhenMultipleChildren_ShouldReturnFirst()
        {
            // Arrange
            var firstChild  = new Mock <IContentData>().Object;
            var secondChild = new Mock <IContentData>().Object;

            _contentLoaderMock
            .Setup(c => c.GetChildren <IContentData>(It.IsAny <ContentReference>()))
            .Returns(new[] { firstChild, secondChild });

            // Act
            var result = ContentLoaderExtensions.GetFirstChild <IContentData>(_contentLoaderMock.Object, null);

            // Assert
            Assert.AreSame(firstChild, result);
        }