Ejemplo n.º 1
0
        public ContentAreaPropertyHandlerTests()
        {
            var contentLoader = Substitute.For <IContentLoader>();

            SetupContentLoader(contentLoader);
            var propertyManager = Substitute.For <IPropertyManager>();

            this._sut = new ContentAreaPropertyHandler(contentLoader, propertyManager, new ContentSerializerSettings());
        }
        public void GivenContentAreaProperty_WhenGetStructuredData_ThenReturnsCorrectValue()
        {
            var contentArea    = CreateContentArea();
            var page           = new StandardPageBuilder().WithMainContentArea(contentArea).Build();
            var serviceLocator = Substitute.For <IServiceLocator>();

            serviceLocator.TryGetExistingInstance(typeof(IPropertyHandler <ContentArea>), out var _).Returns(x =>
            {
                x[1] = new ContentAreaPropertyHandler(this._contentLoader, this._sut, this._contentSerializerSettings);
                return(true);
            });
            serviceLocator.TryGetExistingInstance(typeof(IPropertyHandler <string>), out var _).Returns(x =>
            {
                var selectStrategy = new DefaultSelectStrategy();
                x[1] = new StringPropertyHandler(selectStrategy, selectStrategy, _contentSerializerSettings);
                return(true);
            });
            ServiceLocator.SetLocator(serviceLocator);

            var result = this._sut.GetStructuredData(page, this._contentSerializerSettings);

            result.ShouldContainKey(nameof(StandardPage.MainContentArea));
        }