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 override void SetUp()
        {
            base.SetUp();

            _dataSource = new BindableObjectDataSource();

            _mockRepository = new MockRepository();
            _stubSite       = _mockRepository.Stub <ISite>();
            SetupResult.For(_stubSite.DesignMode).Return(true);
            _dataSource.Site = _stubSite;

            _mockDesignerHost = _mockRepository.StrictMock <IDesignerHost>();
            SetupResult.For(_stubSite.GetService(typeof(IDesignerHost))).Return(_mockDesignerHost);

            var helperStub = _mockRepository.Stub <IDesignModeHelper> ();

            SetupResult.For(helperStub.DesignerHost).Return(_mockDesignerHost);

            _typeResolutionServiceMock = _mockRepository.StrictMock <ITypeResolutionService> ();
            SetupResult.For(_mockDesignerHost.GetService(typeof(ITypeResolutionService))).Return(_typeResolutionServiceMock);

            var typeDiscoveryServiceStub = _mockRepository.Stub <ITypeDiscoveryService> ();

            SetupResult.For(typeDiscoveryServiceStub.GetTypes(null, false)).IgnoreArguments().Return(Assembly.GetExecutingAssembly().GetTypes());
            SetupResult.For(_mockDesignerHost.GetService(typeof(ITypeDiscoveryService))).Return(typeDiscoveryServiceStub);

            // initialize IoC and mixin infrastructure to remove sideeffects in test.
            MixinTypeUtility.GetConcreteMixedType(typeof(SimpleBusinessObjectClass));

            DesignerUtility.SetDesignMode(helperStub);
        }
Exemplo n.º 3
0
        public override void SetUp()
        {
            base.SetUp();

            _dataSource = new BindableObjectDataSource();

            _provider = new BindableObjectProvider();
            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), _provider);
            BusinessObjectProvider.SetProvider(typeof(BindableObjectWithIdentityProviderAttribute), _provider);
        }
        public void SetUp()
        {
            Initialize();

            OptionsMenu = new StubDropDownMenu();
            TextBox     = new StubTextBox();

            Control = MockRepository.GenerateStub <IBocAutoCompleteReferenceValue>();
            Control.Stub(stub => stub.ClientID).Return(c_clientID);
            Control.Stub(stub => stub.ControlType).Return("BocAutoCompleteReferenceValue");
            Control.Stub(stub => stub.GetTextValueName()).Return(c_textValueName);
            Control.Stub(stub => stub.GetKeyValueName()).Return(c_keyValueName);
            Control.Stub(stub => stub.BusinessObjectUniqueIdentifier).Return(c_uniqueidentifier);
            Control.Stub(stub => stub.Command).Return(new BocCommand());
            Control.Command.Type = CommandType.Event;
            Control.Command.Show = CommandShow.Always;
            Control.Stub(stub => stub.SearchServicePath).Return("~/SearchService.asmx");

            Control.Stub(stub => stub.OptionsMenu).Return(OptionsMenu);

            IPage pageStub = MockRepository.GenerateStub <IPage>();

            pageStub.Stub(stub => stub.Form).Return(new HtmlForm());
            Control.Stub(stub => stub.Page).Return(pageStub);

            ClientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>();
            pageStub.Stub(stub => stub.ClientScript).Return(ClientScriptManagerMock);

            BusinessObject = TypeWithReference.Create("MyBusinessObject");
            BusinessObject.ReferenceList = new[]
            {
                TypeWithReference.Create("ReferencedObject 0"),
                TypeWithReference.Create("ReferencedObject 1"),
                TypeWithReference.Create("ReferencedObject 2")
            };

            _dataSource = new BusinessObjectReferenceDataSource();
            _dataSource.BusinessObject = (IBusinessObject)BusinessObject;

            _provider = ((IBusinessObject)BusinessObject).BusinessObjectClass.BusinessObjectProvider;
            _provider.AddService <IBusinessObjectWebUIService> (new ReflectionBusinessObjectWebUIService());

            DataSource = new BindableObjectDataSource {
                Type = typeof(TypeWithReference)
            };
            DataSource.Register(Control);

            StateBag stateBag = new StateBag();

            Control.Stub(mock => mock.Attributes).Return(new AttributeCollection(stateBag));
            Control.Stub(mock => mock.Style).Return(Control.Attributes.CssStyle);
            Control.Stub(mock => mock.CommonStyle).Return(new Style(stateBag));
            Control.Stub(mock => mock.LabelStyle).Return(new Style(stateBag));
            Control.Stub(mock => mock.TextBoxStyle).Return(new SingleRowTextBoxStyle());
            Control.Stub(mock => mock.ControlStyle).Return(new Style(stateBag));

            Control.Stub(stub => stub.GetLabelText()).Return("MyText");
            Control.Stub(stub => stub.ResolveClientUrl(null)).IgnoreArguments().Do((Func <string, string>)(url => url.TrimStart('~')));
            Control.Stub(stub => stub.GetResourceManager()).Return(NullResourceManager.Instance);

            _resourceUrlFactory = new FakeResourceUrlFactory();
        }