コード例 #1
0
        public void Setup()
        {
            _fake = new FakeMaker();

            // Arrange: create a page tree
            _root = FakePage.Create("root");

            _start = FakePage
                     .Create("Start")
                     .ChildOf(_root)
                     .AsStartPage();

            FakePage
            .Create("AboutUs")
            .ChildOf(_root);

            FakePage
            .Create <CustomPageData>("OtherPage")
            .ChildOf(_root)
            .HiddenFromMenu();

            FakePage
            .Create("Contact")
            .ChildOf(_root);

            FakePage
            .Create("Our sub page")
            .ChildOf(_start);

            // Arrange: add the entire page tree to the episerver repository.
            _fake.AddToRepository(_root);
        }
コード例 #2
0
        public void Get_product_by_using_ServiceLocator()
        {
            // Arrange
            var fakePhone = FakeProduct.Create <ProductContent>("My Fake Phone");

            _fake.AddToRepository(fakePhone);

            var loader = ServiceLocator.Current.GetInstance <IContentLoader>();
            var repo   = ServiceLocator.Current.GetInstance <IContentRepository>();

            // Act
            var phoneFromLoader = loader.Get <ProductContent>(fakePhone.Content.ContentLink);
            var phoneFromRepo   = repo.Get <ProductContent>(fakePhone.Content.ContentLink);

            //Assert
            Assert.IsNotNull(phoneFromLoader);
            Assert.IsNotNull(phoneFromRepo);
        }
コード例 #3
0
        public void Get_descendants()
        {
            // Arrange
            var root = FakePage
                       .Create("Root");

            var start = FakePage
                        .Create("Start")
                        .ChildOf(root);

            FakePage
            .Create("About us")
            .ChildOf(start);

            _fake.AddToRepository(root);

            // An instance of IContentRepository that you can use for Dependency Injection
            var repository = _fake.ContentRepository;

            // Or, an instance of IContentLoader that you can use for Dependency Injection
            var loader = _fake.ContentLoader;

            // Act
            var descendants_from_repo   = repository.GetDescendents(root.Content.ContentLink);
            var descendants_from_loader = loader.GetDescendents(root.Content.ContentLink);

            //Assert
            Assert.That(descendants_from_repo.Count(), Is.EqualTo(2));
            Assert.That(descendants_from_loader.Count(), Is.EqualTo(2));
        }