Пример #1
0
        public void TestCategoryAdd()
        {
            string[,] categories =
            { // type,     category,      description
                { "Codecs",  "Audio",         "Codecs for audio"                                                  },
                { "Codecs",  "Video",         "Codecs for video"                                                  },
                { "Codecs",  "Audio & Video", "Codecs for both audio and video"                                   },

                { "Plugins", "Audio/Radio",   "Plugins for audio"                                                 },
                { "Plugins", "Automation",    "Automating MediaPortal tasks"                                      },
                { "Plugins", "EPG/TV",        "EPG - Electronic Program Guide programs/grabbers"                  },
                { "Plugins", "Web",           "Web stuff for Media Portal"                                        },
                { "Plugins", "Video/Movies",  "Plugins for video"                                                 },

                { "Skins",   "16:10",         "Skins created to use on a 16:10 (widescreen) television/monitor."  },
                { "Skins",   "16:9",          "Skins created to use on a 16:9 (widescreen) television/monitor."   },
                { "Skins",   "4:3",           "Skins created to use on a 4:3(non-widescreen) television/monitor." },
                { "Skins",   "Tools",         "Skin tools"                                                        },
            };


            using (ISession session = DatabaseHelper.GetCurrentSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    string     prevType = null;
                    MPItemType mptype   = null;
                    for (int i = 0; i <= categories.GetUpperBound(0); i++)
                    {
                        string type = categories[i, 0];

                        if (type != prevType)
                        { // load new type
                            mptype = session
                                     .CreateQuery("from MPItemType mptype where mptype.Name=?")
                                     .SetString(0, type)
                                     .UniqueResult <MPItemType>();
                            prevType = type;
                        }

                        Assert.NotNull(mptype);
                        Assert.That(mptype.Name, Is.EqualTo(type));

                        MPCategory category = new MPCategory();
                        category.Type        = mptype;
                        category.Name        = categories[i, 1];
                        category.Description = categories[i, 2];
                        session.SaveOrUpdate(category);
                    }
                    transaction.Commit();
                }
            }
        }
Пример #2
0
    public void TestCategoryAdd()
    {
      
      string[,] categories = 
      { // type,     category,      description

        { "Codecs",  "Audio",  "Codecs for audio" },
        { "Codecs",  "Video",  "Codecs for video" },
        { "Codecs",  "Audio & Video",  "Codecs for both audio and video" },

        { "Plugins", "Audio/Radio", "Plugins for audio" },
        { "Plugins", "Automation", "Automating MediaPortal tasks" },
        { "Plugins", "EPG/TV", "EPG - Electronic Program Guide programs/grabbers" },
        { "Plugins", "Web", "Web stuff for Media Portal" },
        { "Plugins", "Video/Movies", "Plugins for video" },

        { "Skins", "16:10", "Skins created to use on a 16:10 (widescreen) television/monitor." },
        { "Skins", "16:9", "Skins created to use on a 16:9 (widescreen) television/monitor." },
        { "Skins", "4:3", "Skins created to use on a 4:3(non-widescreen) television/monitor." },
        { "Skins", "Tools", "Skin tools" },

      };
      

      using (ISession session = DatabaseHelper.GetCurrentSession())
      {
        using (ITransaction transaction = session.BeginTransaction())
        {
          string prevType = null;
          MPItemType mptype = null;
          for (int i = 0; i <= categories.GetUpperBound(0); i++)
          {
            string type = categories[i, 0];

            if (type != prevType)
            { // load new type
              mptype = session
                .CreateQuery("from MPItemType mptype where mptype.Name=?")
                .SetString(0, type)
                .UniqueResult<MPItemType>();
              prevType = type;
            }

            Assert.NotNull(mptype);
            Assert.That(mptype.Name, Is.EqualTo(type));

            MPCategory category = new MPCategory();
            category.Type = mptype;
            category.Name = categories[i, 1];
            category.Description = categories[i, 2];
            session.SaveOrUpdate(category);
          }
          transaction.Commit();
        }
      }

    }