Exemplo n.º 1
0
        public void TestDiagnosticMetadataRenderingForBoundControl_DataSourceWithoutBusinessObject()
        {
            var businessObject = TypeWithReference.Create("MyBusinessObject");

            ((IBusinessObjectBoundControl)Control).Property =
                ((IBusinessObject)businessObject).BusinessObjectClass.GetPropertyDefinition("ReferenceValue");

            var dataSource = new BindableObjectDataSource {
                Type = typeof(TypeWithReference)
            };

            dataSource.Register(Control);
            Control.DataSource = dataSource;

            var renderingContext = CreateRenderingContext();

            BocRendererBase = new TestableBocRendererBase(_resourceUrlFactory, GlobalizationService, RenderingFeatures.WithDiagnosticMetadata);

            BocRendererBase.AddDiagnosticMetadataAttributes(renderingContext);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            renderingContext.Writer.RenderEndTag();

            var document = Html.GetResultDocument();
            var control  = document.DocumentElement;

            control.AssertAttributeValueEquals(DiagnosticMetadataAttributesForObjectBinding.IsBound, "true");
            control.AssertAttributeValueEquals(
                DiagnosticMetadataAttributesForObjectBinding.BoundType,
                "Remotion.ObjectBinding.Web.UnitTests.Domain.TypeWithReference, Remotion.ObjectBinding.Web.UnitTests");
            control.AssertAttributeValueEquals(DiagnosticMetadataAttributesForObjectBinding.BoundProperty, "ReferenceValue");
        }
Exemplo n.º 2
0
        public void TestDiagnosticMetadataRenderingForUnboundControl()
        {
            Control.ReadOnly = true;
            var renderingContext = CreateRenderingContext();

            BocRendererBase = new TestableBocRendererBase(_resourceUrlFactory, GlobalizationService, RenderingFeatures.WithDiagnosticMetadata);

            BocRendererBase.AddDiagnosticMetadataAttributes(renderingContext);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            renderingContext.Writer.RenderEndTag();

            var document = Html.GetResultDocument();
            var control  = document.DocumentElement;

            control.AssertNoAttribute(DiagnosticMetadataAttributesForObjectBinding.DisplayName);
            control.AssertAttributeValueEquals(DiagnosticMetadataAttributes.IsReadOnly, "true");
            control.AssertAttributeValueEquals(DiagnosticMetadataAttributesForObjectBinding.IsBound, "false");
            control.AssertNoAttribute(DiagnosticMetadataAttributesForObjectBinding.BoundType);
            control.AssertNoAttribute(DiagnosticMetadataAttributesForObjectBinding.BoundProperty);
        }