Пример #1
0
        public void MsiModelCheckInstallDirectoryForDeleting()
        {
            MsiModel model = new MsiModel();

              // Проверим на удаление предопределенный элемент.
              Assert.IsFalse(model.CheckInstallDirectoryForDeleting(MsiModel.PredefinedInstallDirectories[0]));

              // Добавим директорию и проверим на удаление ее.
              model.InstallDirectories.Add("QQQ");
              Assert.IsTrue(model.CheckInstallDirectoryForDeleting("QQQ"));

              // Добавим в модель компонент.
              IWixElement component = model.AddItem(typeof(WixComponentElement));
              // Добавим в компонент файл.
              WixFileElement file = model.AddItem(typeof(WixFileElement)) as WixFileElement;

              // У первого файла выставим директорию QQQ и попробуем удалить ее.
              file.InstallDirectory = "QQQ";
              Assert.IsFalse(model.CheckInstallDirectoryForDeleting("QQQ"));
        }
Пример #2
0
        public void MsiModelAddItems()
        {
            MsiModel model = new MsiModel();
              // Запомним текущее количество.
              int count = model.RootItem.Items.Count;

              // Добавляем Feature к корневому элементу.
              IWixElement feature = model.AddItem(typeof(WixFeatureElement));
              Assert.AreEqual(++count, model.RootItem.Items.Count);
              Assert.IsNotNull(feature);
              Assert.AreEqual(feature, model.RootItem.Items[count - 1]);
              Assert.AreEqual(feature, model.SelectedItem);

              // Добавим компонент к корневому элементу.
              model.SelectedItem = null;
              IWixElement componetFirst = model.AddItem(typeof(WixComponentElement));
              Assert.AreEqual(++count, model.RootItem.Items.Count);
              Assert.IsNotNull(componetFirst);
              Assert.AreEqual(componetFirst, model.RootItem.Items[count - 1]);
              Assert.AreEqual(componetFirst, model.SelectedItem);

              // Добавим компонент к созданной Feature.
              model.SelectedItem = feature;
              IWixElement componetSecond = model.AddItem(typeof(WixComponentElement));
              Assert.AreEqual(1, feature.Items.Count);
              Assert.IsNotNull(componetSecond);
              Assert.AreEqual(componetSecond, feature.Items[0]);
              Assert.AreEqual(componetSecond, model.SelectedItem);

              // Добавим компонент к корневому элементу.
              model.SelectedItem = null;
              IWixElement componetThird = model.AddItem(typeof(WixComponentElement));
              Assert.AreEqual(++count, model.RootItem.Items.Count);
              Assert.IsNotNull(componetThird);
              Assert.AreEqual(componetThird, model.RootItem.Items[count - 1]);
              Assert.AreEqual(componetThird, model.SelectedItem);
        }
Пример #3
0
        public void MsiModelDeleteItem()
        {
            MsiModel model = new MsiModel();
              // Запомним текущее количество.
              int count = model.RootItem.Items.Count;

              // Добавляем Feature к корневому элементу.
              IWixElement feature = model.AddItem(typeof(WixFeatureElement));
              Assert.AreEqual(++count, model.RootItem.Items.Count);
              Assert.AreEqual(feature, model.SelectedItem);

              // Добавляем Feature к корневому элементу.
              model.SelectedItem = null;
              feature = model.AddItem(typeof(WixFeatureElement));
              Assert.AreEqual(++count, model.RootItem.Items.Count);
              Assert.AreEqual(feature, model.SelectedItem);

              // Удаляем выделенный элемент.
              model.RemoveSelectedItem();
              Assert.AreEqual(--count, model.RootItem.Items.Count);
              Assert.IsNull(model.SelectedItem);
        }
Пример #4
0
 public void MsiModelSelectedItemInitializedWrong()
 {
     BuilderModel model = new MsiModel();
       model.Items.Add(new WixFeatureElement());
       IWixElement element = new WixFeatureElement();
       model.SelectedItem = element;
       Assert.Fail();
 }
Пример #5
0
        public void MsiModelSelectedItemInitializedSuccessful()
        {
            BuilderModel model = new MsiModel();
              IWixElement element = new WixFeatureElement();
              model.Items.Add(element);
              model.SelectedItem = element;
              Assert.AreEqual(element, model.SelectedItem);

              element = new WixFeatureElement();
              model.Items[0].Items.Add(element);
              model.SelectedItem = element;
              Assert.AreEqual(element, model.SelectedItem);
        }
Пример #6
0
 public void MsiModelSelectedItemCreated()
 {
     BuilderModel model = new MsiModel();
       Assert.IsNull(model.SelectedItem);
 }
Пример #7
0
 public void MsiModelRootElement()
 {
     BuilderModel model = new MsiModel();
       Assert.IsInstanceOfType(model.RootItem, typeof(WixFeatureElement));
 }
Пример #8
0
 public void MsiModelGetElementCommands()
 {
     BuilderModel model = new MsiModel();
       CommandMetadata[] metadata = model.GetElementCommands();
       Assert.IsNotNull(metadata);
       Assert.IsTrue(metadata.Length > 0);
 }