public void SetUp() { Initialize(); OptionsMenu = new StubDropDownMenu(); DropDownList = new StubDropDownList(); Control = MockRepository.GenerateStub <IBocReferenceValue>(); Control.Stub(stub => stub.ClientID).Return(c_clientID); Control.Stub(stub => stub.ControlType).Return("BocReferenceValue"); Control.Stub(stub => stub.Command).Return(new BocCommand()); Control.Stub(stub => stub.BusinessObjectUniqueIdentifier).Return(c_uniqueIdentifier); Control.Command.Type = CommandType.Event; Control.Command.Show = CommandShow.Always; Control.Stub(stub => stub.OptionsMenu).Return(OptionsMenu); IPage pageStub = MockRepository.GenerateStub <IPage>(); pageStub.Stub(stub => stub.WrappedInstance).Return(new PageMock()); 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()); 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.LabelStyle).Return(new Style(stateBag)); Control.Stub(mock => mock.DropDownListStyle).Return(new DropDownListStyle()); Control.Stub(mock => mock.ControlStyle).Return(new Style(stateBag)); Control.Stub(stub => stub.GetValueName()).Return(c_valueName); Control.Stub(stub => stub.PopulateDropDownList(Arg <DropDownList> .Is.NotNull)) .WhenCalled( invocation => { foreach (var item in BusinessObject.ReferenceList) { ((DropDownList)invocation.Arguments[0]).Items.Add(new ListItem(item.DisplayName, item.UniqueIdentifier)); } }); 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); _resourceUrlFactoryStub = new FakeResourceUrlFactory(); }
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(); }