Example #1
0
        public List<Tab> GetTabsCollectionByKey(string tabKey)
        {
            var list = new List<Tab>();

             //Get the collection from xml

             try
             {

                 var tabpage = GetRawTabPageByKey(tabKey);

                 var tabs =
                     from tab in tabpage.Elements("tab")
                     select new
                                {
                                    Caption = tab.Element("caption").Value,
                                    ID = tab.Attribute("id").Value,

                                    //whereString = tab.Element("where").Element("string").Value,
                                    //whereValues = from cond in tab.Element("where").Element("values").Elements("value") select new
                                    //                                                                              {
                                    //                                                                                  Value = cond.Value
                                    //                                                                              }

                                };

                 var tabIndex = 1;
                 foreach (var tab in tabs)
                 {
                     var tabobj = new Tab(tab.Caption, tab.ID,tabIndex);
                     tabIndex++;

                     list.Add(tabobj); ;
                 }
             }
             catch (IndexOutOfRangeException ex)
             {
                 throw new IndexOutOfRangeException(ex.Message);
             }
             catch (NullReferenceException)
             {
                 ThrowBadXML();
             }

            return list;
        }
        //TODO add some error handling for sure there can be found some
        private TabsViewModel CreateViewModel(string caption)
        {
            var tabID = fixture.CreateAnonymous<string>();

            var currentTab = new Tab(caption, tabID, 0);
            fixture.Customize<TabsViewModel>(m => m.With(x=> x.Tabs, new List<Tab>()).Do(x => x.Tabs.Add(currentTab)).With(x => x.TabId, tabID).With(x=>x.ShortTitle,"shorttitle"));

            var viewModel = fixture.CreateAnonymous<TabsViewModel>();
            return viewModel;
        }