public void Test_SetViewBuilder_ShouldSet() { //---------------Set up test pack------------------- var mockPageProvider = MockRepository.GenerateStub <PageProvider <FakeBO> >(); IViewBuilder viewBuilder = MockRepository.GenerateStub <IViewBuilder>(); var list = new CachedBindingListViewSpy <FakeBO>(mockPageProvider); //---------------Assert Precondition---------------- Assert.IsNull(list.ViewBuilder); //---------------Execute Test ---------------------- list.ViewBuilder = viewBuilder; //---------------Test Result ----------------------- Assert.AreSame(viewBuilder, list.ViewBuilder); }
public void Test_GetItemProperties_WhenNotHasViewBuilder_TypeDescriptorGetProperties() { //---------------Set up test pack------------------- var mockPageProvider = MockRepository.GenerateStub <PageProvider <FakeBO> >(); var list = new CachedBindingListViewSpy <FakeBO>(mockPageProvider); //---------------Assert Precondition---------------- Assert.IsNull(list.ViewBuilder); //---------------Execute Test ---------------------- var pds = list.GetItemProperties(new PropertyDescriptor[0]); //---------------Test Result ----------------------- var propertyInfos = typeof(FakeBO).GetProperties(); Assert.AreEqual(propertyInfos.Length, pds.Count); }
public void Test_Filter_ReturnsThePageProviderFilter() { //---------------Set up test pack------------------- var mockPageProvider = MockRepository.GenerateStub <PageProvider <FakeBO> >(); const string expectedFilter = "FakeBOName = 1"; mockPageProvider.Filter = expectedFilter; var list = new CachedBindingListViewSpy <FakeBO>(mockPageProvider); //---------------Assert Precondition---------------- Assert.AreEqual(expectedFilter, mockPageProvider.Filter); //---------------Execute Test ---------------------- string actualFilter = list.Filter; //---------------Test Result ----------------------- Assert.AreEqual(expectedFilter, actualFilter); }
public void Test_GetItemProperties_WhenHasViewBuilder_ShouldReturnViewBuidlersGetGridView() { //---------------Set up test pack------------------- var mockPageProvider = MockRepository.GenerateStub <PageProvider <FakeBO> >(); IViewBuilder viewBuilder = MockRepository.GenerateStub <IViewBuilder>(); viewBuilder.Stub(builder => builder.GetPropertyDescriptors()).Return( new PropertyDescriptorCollection(new PropertyDescriptor[0])); var list = new CachedBindingListViewSpy <FakeBO>(mockPageProvider) { ViewBuilder = viewBuilder }; //---------------Assert Precondition---------------- Assert.AreSame(viewBuilder, list.ViewBuilder); //---------------Execute Test ---------------------- var pds = list.GetItemProperties(new PropertyDescriptor[0]); //---------------Test Result ----------------------- Assert.AreEqual(0, pds.Count); }