public void TestEmulateChangeItemEvent()
 {
     NativeListControl list = new NativeListControl(testDlg.IdentifyFromDialogId(1037));
     Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg,
         delegate
         {
             LVITEM item = new LVITEM();
             item.iItem = 1;
             item.mask = LVIF.TEXT;
             item.pszText = "zzz";
             list.EmulateChangeItem(item); 
         },
         new CodeInfo(1037, NativeMethods.WM_NOTIFY, LVN_ITEMCHANGING),
         new CodeInfo(1037, NativeMethods.WM_NOTIFY, LVN_ITEMCHANGED)
     ));
 }
 public void TestEmulateChangeItemEventAsync()
 {
     NativeListControl list = new NativeListControl(testDlg.IdentifyFromDialogId(1038));
     LVITEM item = new LVITEM();
     item.iItem = 1;
     item.mask = LVIF.TEXT;
     item.pszText = "zzz";
     Async async = new Async();
     list.EmulateChangeItem(item, async);
     Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async));
 }
        public void TestSetGetItem()
        {
            NativeListControl list = new NativeListControl(testDlg.IdentifyFromDialogId(1037));

            LVITEM setData = new LVITEM();
            LVITEM getData = new LVITEM();
            foreach (LVIF element in (LVIF[])Enum.GetValues(typeof(LVIF)))
            {
                setData.mask |= element;
                getData.mask |= element;
            }
            foreach (LVIS element in (LVIS[])Enum.GetValues(typeof(LVIS)))
            {
                setData.stateMask |= element;
                getData.stateMask |= element;
            }

            //アイテムの変更
            setData.iItem = 2;
            setData.iSubItem = 0;
            setData.state = LVIS.CUT;
            setData.pszText = "abc";
            setData.iImage = 2;
            setData.lParam = new IntPtr(3);
            list.EmulateChangeItem(setData);

            //変更結果の確認
            getData.iItem = 2;
            getData.iSubItem = 0;
            list.GetItem(getData);
            Assert.AreEqual(setData.iItem, getData.iItem);
            Assert.AreEqual(setData.iSubItem, getData.iSubItem);
            Assert.AreEqual(setData.state, getData.state);
            Assert.AreEqual(setData.pszText, getData.pszText);
            Assert.AreEqual(setData.iImage, getData.iImage);
            Assert.AreEqual(setData.lParam, getData.lParam);

            //非同期でも同様の効果があることを確認。
            Async a = new Async();
            setData.pszText = "efg";
            list.EmulateChangeItem(setData, a);
            while (!a.IsCompleted)
            {
                Thread.Sleep(10);
            }
            list.GetItem(getData);
            Assert.AreEqual(setData.pszText, getData.pszText);
        }