Exemplo n.º 1
0
        public void TestTypeAdd()
        {
            string[,] types =
            {
                { "Codecs",             "Different multimedia codecs."                                  },
                { "Drivers",            "Drivers for different hardware"                                },
                { "HTPC Customization", "Customize your HTPC the way you like it"                       },
                { "Plugins",            "Plugins for extended functionality"                            },
                { "Skins",              "Download skins to make Media Portal look the way YOU want it." },
                { "System Utilities",   "System utillties to aid your way."                             },
            };

            using (ISession session = DatabaseHelper.GetCurrentSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    for (int i = 0; i <= types.GetUpperBound(0); i++)
                    {
                        MPItemType type = new MPItemType();
                        type.Name        = types[i, 0];
                        type.Description = types[i, 1];
                        session.SaveOrUpdate(type);
                    }
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 3
0
    public void TestTypeAdd()
    {
      string[,] types = 
      {
        { "Codecs", "Different multimedia codecs." },
        { "Drivers", "Drivers for different hardware" },
        { "HTPC Customization", "Customize your HTPC the way you like it" },
        { "Plugins", "Plugins for extended functionality" },
        { "Skins", "Download skins to make Media Portal look the way YOU want it." },
        { "System Utilities", "System utillties to aid your way." },
      };

      using (ISession session = DatabaseHelper.GetCurrentSession())
      {
        using (ITransaction transaction = session.BeginTransaction())
        {
          for (int i = 0; i <= types.GetUpperBound(0); i++)
          {
            MPItemType type = new MPItemType();
            type.Name = types[i, 0];
            type.Description = types[i, 1];
            session.SaveOrUpdate(type);
          }
          transaction.Commit();
        }
      }

    }