Exemplo n.º 1
0
 public void bindTo(ILookupList list)
 {
     list.clear();
     foreach(ILookupDTO dto in items) {
         list.add(dto);
     }
 }
 public void beforTest()
 {
     mocks = new Mockery();
     view = mocks.NewMock<IPlaylistSelectorView>();
     task = mocks.NewMock<IPlaylistSelectorTask>();
     lookupList = mocks.NewMock<ILookupList>();
     presenter = new PlaylistSelectorPresenter(view, task);
 }
Exemplo n.º 3
0
 public void BindTo(ILookupList list)
 {
     list.Clear();
     foreach (object dto in items)
     {
         list.Add(dto.ToString());
     }
 }
Exemplo n.º 4
0
        public void InitializeView( )
        {
            //imposto il testo per la label del proprietario
            _view.SetTestoProprietario();

            ILookupList l = _view.ComboRegioni;
            //inizializzo la view con la lista delle regioni
            StringListBinder b = new StringListBinder(GeoLocationFacade.Instance().GetGeoHandler().GetListaNomiRegioni());

            b.BindTo(l);
            //seleziono il primo elemento
            l.SelectAt(0);



            if (_type == ActionType.New)
            {
                _view.IsBilancioOptionsEnabled = true;
                _view.IsFileInfoVisible        = true;
                //poichè il tipo regionale è impostato all'inizio
                //disabilito il combo province
                SetInterfaceFromType();
                _view.SelectedYear = DateTime.Now.Year;
            }
            else
            {
                //carico i dati dal dto
                RendicontoHeaderDTO dto = _service.RendicontoHeader;
                _view.SelectedProprietario = dto.Proprietario;
                _view.SelectedYear         = dto.Anno;

                if (!_view.IsFreeTemplate)
                {
                    SetInterfaceFromType();
                    _view.IsRegionaleTypeChecked = dto.IsRegionale;

                    _view.SelectedRegion = dto.Regione;

                    _view.SelectedProvince = dto.Provincia;

                    _view.IsBilancioOptionsEnabled = false;
                    _view.IsFileInfoVisible        = false;
                }
                else
                {
                    _view.IsBilancioOptionsVisible = false;
                    _view.IsFileInfoVisible        = false;
                    _view.AreGeoComboVisible       = true;

                    SetInterfaceFromType();
                    _view.IsRegionaleTypeChecked = dto.IsRegionale;

                    _view.SelectedRegion = dto.Regione;

                    _view.SelectedProvince = dto.Provincia;
                }
            }
        }
        public void TestSimpleLookupListOptions()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"<simpleLookupList options=""option1|option2|option3"" />");
            ISimpleLookupList source = (ISimpleLookupList)lookupList;

            Assert.AreEqual(3, source.GetLookupList().Count, "LookupList should have three keyvaluepairs");
        }
Exemplo n.º 6
0
        private static UIGridColumn GetGridColumn(IClassDef classDef, ILookupList lookupList)
        {
            UIGridColumnSpy gridColumn = new UIGridColumnSpy();

            classDef.GetLookupList(gridColumn.PropertyName);
            classDef.Stub(def => def.GetLookupList(gridColumn.PropertyName)).Return(lookupList);

            gridColumn.SetClassDef(classDef);
            return(gridColumn);
        }
Exemplo n.º 7
0
        private static Type GetPropertyType(IClassDef classDef, string propertyName)
        {
            ILookupList lookupList   = classDef.GetLookupList(propertyName);
            Type        propertyType = classDef.GetPropertyType(propertyName);

            if (lookupList != null && !(lookupList is NullLookupList))
            {
                propertyType = typeof(object);
            }
            return(propertyType);
        }
Exemplo n.º 8
0
    public void BindTo(ILookupList list)
    {
        mList = list;

        mList.Clear();

        foreach (ILookupDTO dto in dtos)
        {
            mList.Add(dto);
        }
    }
        public void Test_LookupList_ShouldBeNull()
        {
            //---------------Set up test pack-------------------

            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDescriptor.LookupList;

            //---------------Test Result -----------------------
            Assert.IsNull(lookupList);
        }
        public virtual void TestBusinessObjectLookupListWithCriteria()
        {
            //---------------Set up test pack-------------------
            const string xml = @"<businessObjectLookupList class=""MyBO"" assembly=""Habanero.Test"" criteria=""TestProp=Test"" />";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ILookupList lookupList = _loader.LoadLookupList(xml);
            //---------------Test Result -----------------------
            IBusinessObjectLookupList source = (IBusinessObjectLookupList)lookupList;

            Assert.AreEqual("TestProp=Test", source.CriteriaString);
        }
Exemplo n.º 11
0
        public void Test_LookupList_WhenNullClassDef_ShouldReturnNullLookupList()
        {
            //---------------Set up test pack-------------------
            UIGridColumn gridColumn = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(gridColumn.ClassDef);
            //---------------Execute Test ----------------------
            ILookupList actualLList = gridColumn.LookupList;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <NullLookupList>(actualLList);
        }
        public virtual void TestBusinessObjectLookupListWithSort()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            const string xml = @"<businessObjectLookupList class=""MyBO"" assembly=""Habanero.Test"" sort=""TestProp asc"" />";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ILookupList lookupList = _loader.LoadLookupList(xml);
            //---------------Test Result -----------------------
            IBusinessObjectLookupList source = (IBusinessObjectLookupList)lookupList;

            Assert.AreEqual("TestProp asc", source.SortString);
        }
        public void TestSimpleLookupListOptionsAndItems()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"
						<simpleLookupList options=""option1|option2|option3"" >
							<item display=""s1"" value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
							<item display=""s2"" value=""{B89CC2C9-4CBB-4519-862D-82AB64796A58}"" />
                        </simpleLookupList>
					"                    );
            ISimpleLookupList source = (ISimpleLookupList)lookupList;

            Assert.AreEqual(5, source.GetLookupList().Count, "LookupList should have 5 keyvaluepairs");
        }
        public void TestDatabaseLookupListWithClassDef()
        {
            XmlDatabaseLookupListLoader loader = new XmlDatabaseLookupListLoader(new DtdLoader(), GetDefClassFactory());

            MyBO.LoadDefaultClassDef();
            ILookupList def =
                loader.LoadLookupList(
                    @"<databaseLookupList sql=""Source"" class=""MyBO"" assembly=""Habanero.Test"" />");
            IDatabaseLookupList source = (IDatabaseLookupList)def;

            Assert.AreEqual("MyBO", source.ClassName);
            Assert.AreEqual("Habanero.Test", source.AssemblyName);
            Assert.AreEqual(10000, source.TimeOut);
        }
Exemplo n.º 15
0
        public void Test_LookupList_WhenNotSet_ShouldBeNull()
        {
            //---------------Set up test pack-------------------
            IClassDef                 classDef       = MockRepository.GenerateStub <IClassDef>();
            IUIGridColumn             gridColumn     = GetGridColumnStub(classDef);
            PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn);

            //---------------Assert Precondition----------------
            Assert.IsNull(classDef.GetLookupList(gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDescriptor.LookupList;

            //---------------Test Result -----------------------
            Assert.IsNull(lookupList);
        }
Exemplo n.º 16
0
        private void LoadSearchCombo(ILookupList list, string property)
        {
            if (!string.IsNullOrEmpty(list.SelectedItem))
            {
                return;
            }

            //inizializzo la view con la lista delle regioni
            IList            l1 = GetList(_service.GetRiferimentoLista(property));
            StringListBinder b  = new StringListBinder(l1);

            b.BindTo(list);
            //seleziono il primo elemento
            list.SelectAt(-1);
        }
        public void TestSimpleLookupListNoItems()
        {
            try
            {
                ILookupList lookupList = _loader.LoadLookupList(@"
					<simpleLookupList></simpleLookupList>
				"                );
                Assert.Fail("Expected to throw an InvalidXmlDefinitionException");
            }
            //---------------Test Result -----------------------
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("A 'simpleLookupList' element does not contain any 'item' elements or any items in the 'options' attribute.  It should contain one or more ", ex.Message);
            }
        }
Exemplo n.º 18
0
        public void Test_LookupList_ShouldReturnClassDefsLookupList()
        {
            //---------------Set up test pack-------------------
            var          expectedLList = MockRepository.GenerateStub <ILookupList>();
            var          classDef      = MockRepository.GenerateStub <IClassDef>();
            UIGridColumn gridColumn    = GetGridColumn(classDef, expectedLList);

            //---------------Assert Precondition----------------
            Assert.AreSame(classDef, gridColumn.ClassDef);
            Assert.AreSame(expectedLList, classDef.GetLookupList(gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            ILookupList actualLList = gridColumn.LookupList;

            //---------------Test Result -----------------------
            Assert.AreSame(expectedLList, actualLList);
        }
        public virtual void TestBusinessObjectLookupList()
        {
            //---------------Set up test pack-------------------
            const string xml = @"<businessObjectLookupList class=""MyBO"" assembly=""Habanero.Test"" />";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ILookupList lookupList = _loader.LoadLookupList(xml);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(IBusinessObjectLookupList), lookupList);
            IBusinessObjectLookupList source = (IBusinessObjectLookupList)lookupList;

            //Assert.AreEqual(5, source.GetLookupList().Count, "LookupList should have 5 keyvaluepairs");
            Assert.AreEqual("MyBO", source.ClassName);
            Assert.AreEqual("Habanero.Test", source.AssemblyName);
        }
Exemplo n.º 20
0
        private static void createLookupListXml(XmlElement propDMElement, IPropDef propDef)
        {
            ILookupList lookupListBase = propDef.LookupList;

            if (lookupListBase == null)
            {
                return;
            }
            //IClassDef lookupClass = lookupList.LookupClass;
            XmlElement lookupElement;

            if (lookupListBase is ISimpleLookupList)
            {
                ISimpleLookupList lookupList = (ISimpleLookupList)lookupListBase;

                lookupElement = XmlUtilities.createXmlElement(propDMElement, "simpleLookupList");
                foreach (KeyValuePair <string, string> pair in lookupList.GetLookupList())
                {
                    XmlElement addElement = XmlUtilities.createXmlElement(lookupElement, "item");
                    XmlUtilities.setXmlAttribute(addElement, "display", pair.Key);
                    XmlUtilities.setXmlAttribute(addElement, "value", pair.Value);
                }
            }

            if (lookupListBase is IDatabaseLookupList)
            {
                IDatabaseLookupList lookupList = (IDatabaseLookupList)lookupListBase;
                lookupElement = XmlUtilities.createXmlElement(propDMElement, "databaseLookupList");
                XmlUtilities.setXmlAttribute(lookupElement, "sql", lookupList.SqlString);
                XmlUtilities.setXmlAttribute(lookupElement, "timeout", lookupList.TimeOut, 10000);
                XmlUtilities.setXmlAttribute(lookupElement, "class", lookupList.ClassName);
                XmlUtilities.setXmlAttribute(lookupElement, "assembly", lookupList.AssemblyName);
            }

            if (lookupListBase is IBusinessObjectLookupList)
            {
                IBusinessObjectLookupList lookupList = (IBusinessObjectLookupList)lookupListBase;
                lookupElement = XmlUtilities.createXmlElement(propDMElement, "businessObjectLookupList");
                XmlUtilities.setXmlAttribute(lookupElement, "class", lookupList.ClassName);
                XmlUtilities.setXmlAttribute(lookupElement, "assembly", lookupList.AssemblyName);
                XmlUtilities.setXmlAttribute(lookupElement, "criteria", lookupList.CriteriaString);
                XmlUtilities.setXmlAttribute(lookupElement, "timeout", lookupList.TimeOut, 10000);
                //TODO Mark 28 Sep 2009: Check that this sort string is getting built correctly
                XmlUtilities.setXmlAttribute(lookupElement, "sort", lookupList.SortString);
            }
        }
        public void TestSimpleLookupListItemHasNoValue()
        {
            try
            {
                ILookupList lookupList = _loader.LoadLookupList(@"
				    <simpleLookupList>
						<item display=""s1"" />
                    </simpleLookupList>
				"                );
                Assert.Fail("Expected to throw an InvalidXmlDefinitionException");
            }
            //---------------Test Result -----------------------
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("An 'item' is missing a 'value' attribute that specifies the value to store for the given property", ex.Message);
            }
        }
        public void TestSimpleLookupListItemHasNoDisplay()
        {
            try
            {
                ILookupList lookupList = _loader.LoadLookupList(@"
					<simpleLookupList>
						<item value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
                    </simpleLookupList>
				"                );
                Assert.Fail("Expected to throw an InvalidXmlDefinitionException");
            }
            //---------------Test Result -----------------------
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("An 'item' is missing a 'display' attribute that specifies the string to show to the user in a display", ex.Message);
            }
        }
Exemplo n.º 23
0
        public void Test_LookupList_WhenSetOnProp_ShouldReturnList()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn         = GetGridColumnStub();
            ILookupList   expectedLookupList = MockRepository.GenerateStub <ILookupList>();

            gridColumn.Stub(column => column.LookupList).Return(expectedLookupList);

            PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(gridColumn.LookupList);
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDescriptor.LookupList;

            //---------------Test Result -----------------------
            Assert.AreSame(expectedLookupList, lookupList);
        }
Exemplo n.º 24
0
        public void Test_LookupList_WhenNotSet_ShouldBeNull()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MockRepository.GenerateStub <IClassDef>();

            classDef.ClassType = typeof(FakeBO);
            IUIGridColumn gridColumn = GetGridColumnStub(classDef);

            gridColumn.PropertyName = "FakeObjectNotABo";
            PropertyDescriptorReflectiveProp propDescriptor = new PropertyDescriptorReflectiveProp(gridColumn);

            //---------------Assert Precondition----------------
            Assert.IsNull(classDef.GetLookupList(gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDescriptor.LookupList;

            //---------------Test Result -----------------------
            Assert.IsNull(lookupList);
        }
        public void TestSimpleLookupListItems()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"
						<simpleLookupList>
							<item display=""s1"" value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
							<item display=""s2"" value=""{B89CC2C9-4CBB-4519-862D-82AB64796A58}"" />
                        </simpleLookupList>
					"                    );
            ISimpleLookupList           source     = (ISimpleLookupList)lookupList;
            Dictionary <string, string> dictionary = source.GetLookupList();

            Assert.AreEqual(2, dictionary.Count, "LookupList should have 2 keyvaluepairs");
            Assert.IsTrue(dictionary.ContainsKey("s1"), "should contain the display value 's1' as a key");
            Assert.AreEqual(new Guid("{C2887FB1-7F4F-4534-82AB-FED92F954783}").ToString("D"), dictionary["s1"]);
            Assert.IsTrue(dictionary.ContainsKey("s2"), "should contain the display value 's2' as a key");
            Assert.AreEqual(new Guid("{B89CC2C9-4CBB-4519-862D-82AB64796A58}").ToString("D"), dictionary["s2"]);
        }
 private static object GetLookupListValue(ILookupList lookupList)
 {
     return (((lookupList == null) || (lookupList is NullLookupList)) ? null : RandomValueGen.GetRandomLookupListValue(lookupList.GetLookupList()));
 }
 private static object GetLookupListValue(ILookupList lookupList)
 {
     return(((lookupList == null) || (lookupList is NullLookupList)) ? null : RandomValueGen.GetRandomLookupListValue(lookupList.GetLookupList()));
 }
Exemplo n.º 28
0
        private void CreateColumnForUIDef(IClassDef classDef, IUIGrid gridDef)
        {
            foreach (IUIGridColumn gridColDef in gridDef)
            {
                IDataGridViewColumn col;
                if (gridColDef.GridControlTypeName == "DataGridViewComboBoxColumn")
                {
                    IDataGridViewComboBoxColumn comboBoxCol = _controlFactory.CreateDataGridViewComboBoxColumn();

                    IPropDef    propDef = GetPropDef(classDef, gridColDef);
                    ILookupList source  = null;
                    if (propDef != null)
                    {
                        source = propDef.LookupList;
                    }
                    if (source != null)
                    {
                        DataTable table = new DataTable();
                        table.Columns.Add("id");
                        table.Columns.Add("str");

                        table.LoadDataRow(new object[] { "", "" }, true);
                        foreach (KeyValuePair <string, string> pair in source.GetLookupList())
                        {
                            table.LoadDataRow(new object[] { pair.Value, pair.Key }, true);
                        }

                        comboBoxCol.DataSource = table;
                        // ReSharper disable ConditionIsAlwaysTrueOrFalse
                        //Hack_: This null check has been placed because of a Gizmox bug_
                        //  We posted this at: http://www.visualwebgui.com/Forums/tabid/364/forumid/29/threadid/12420/scope/posts/Default.aspx
                        //  It is causing a StackOverflowException on ValueMember because the DataSource is still null

                        if (comboBoxCol.DataSource != null)

                        {
                            comboBoxCol.ValueMember   = "str";
                            comboBoxCol.DisplayMember = "str";
                        }
                        // ReSharper restore ConditionIsAlwaysTrueOrFalse
                    }
                    comboBoxCol.DataPropertyName = gridColDef.PropertyName;
                    col = comboBoxCol;
                    this.GridBase.Columns.Add(col);
                }
                else if (gridColDef.GridControlTypeName == "DataGridViewCheckBoxColumn")
                {
                    col = _controlFactory.CreateDataGridViewCheckBoxColumn();
                    this.GridBase.Columns.Add(col);
                }
                else
                {
                    col = CreateCustomColumn(gridColDef);
                }
                col.HeaderText       = gridColDef.GetHeading();
                col.Name             = gridColDef.PropertyName;
                col.DataPropertyName = gridColDef.PropertyName;
                col.Width            = gridColDef.Width;
                col.Visible          = gridColDef.Width != 0;
                col.SortMode         = DataGridViewColumnSortMode.Automatic;
                col.ReadOnly         = !gridColDef.Editable;
                Type propertyType = GetPropertyType(classDef, gridColDef.PropertyName);
                if (propertyType != typeof(object))
                {
                    col.ValueType = propertyType;
                }
                SetupColumnWithDefParameters(col, gridColDef, propertyType);
            }
        }
Exemplo n.º 29
0
        private static UIGridColumn GetGridColumn(IClassDef classDef, ILookupList lookupList)
        {
            UIGridColumnSpy gridColumn = new UIGridColumnSpy();
            classDef.GetLookupList(gridColumn.PropertyName);
            classDef.Stub(def => def.GetLookupList(gridColumn.PropertyName)).Return(lookupList);

            gridColumn.SetClassDef(classDef);
            return gridColumn;
        }