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"); }
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); }