示例#1
0
        private static bool AddOrRemove(KeePassLib.PwEntry pe)
        {
            if (!Enabled)
            {
                return(false);
            }
            int        idx         = IndexOf(pe);
            int        iPwColIndex = GetPwColumnIndex();
            SingleItem si          = m_lItems.Find(x => x.Entry.Uuid.Equals(pe.Uuid));
            bool       bAdd        = si == null;

            if (bAdd)
            {
                si = new SingleItem(pe);
                m_lItems.Add(si);
            }
            else
            {
                m_lItems.Remove(si);
            }
            if (idx >= 0 && iPwColIndex >= 0)
            {
                if (bAdd)
                {
                    EntriesListView.Items[idx].SubItems[iPwColIndex].Text = pe.Strings.ReadSafe(KeePassLib.PwDefs.PasswordField);
                }
                else
                {
                    EntriesListView.Items[idx].SubItems[iPwColIndex].Text = KeePassLib.PwDefs.HiddenPassword;
                }
            }
            return(true);
        }
示例#2
0
    public void ShowHeroesownedNeedHospital()
    {
        ResetPage();
        List <GDEHeroData> heroes  = SDDataManager.Instance.PlayerData.herosOwned;
        List <GDEHeroData> results = new List <GDEHeroData>();

        //
        for (int i = 0; i < heroes.Count; i++)
        {
            if (heroes[i].status == 2 || heroes[i].status == 3)//该角色已遭重创(包括正在救治中)
            {
                results.Add(heroes[i]);
            }
        }
        for (int i = 0; i < heroes.Count; i++)
        {
            if (heroes[i].status != 2 && heroes[i].status != 3)//该角色未遭重创且不在治疗室中
            {
                results.Add(heroes[i]);
            }
        }
        //
        for (int i = 0; i < results.Count; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initInjuriedHero(results[i]);
            items.Add(_s);
        }
    }
示例#3
0
        public void AddItem()
        {
            UnitTestContext context = GetContext();

            DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName;
            WcfProxy.DefaultUrl      = cslalighttest.Properties.Resources.RemotePortalUrl;
            ApplicationContext.GlobalContext.Clear();

            RootSingleItemsList list;

            RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) =>
            {
                if (e.Error != null)
                {
                    context.Assert.Fail(e.Error.Message);
                }
                else
                {
                    context.Assert.IsNotNull(e.Object);
                    list            = e.Object;
                    SingleItem item = SingleItem.GetSingleItem();
                    list.Add(item);
                    context.Assert.AreEqual(3, list.Count, "Count should be 3");
                    context.Assert.IsTrue(list[2].IsNew, "Object should be new");
                }
                context.Assert.Success();
            }
                                                       );
            context.Complete();
        }
示例#4
0
        public void RemoveNewItem()
        {
            UnitTestContext context = GetContext();

            DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName;
            WcfProxy.DefaultUrl      = cslalighttest.Properties.Resources.RemotePortalUrl;
            ApplicationContext.GlobalContext.Clear();

            RootSingleItemsList list;

            RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) =>
            {
                context.Assert.IsNotNull(e.Object);
                list            = e.Object;
                SingleItem item = SingleItem.GetSingleItem();
                list.Add(item);
                context.Assert.AreEqual(3, list.Count, "Count should be 3");
                context.Assert.IsTrue(list[2].IsNew, "Object should be new");

                list.RemoveAt(2);
                context.Assert.AreEqual(2, list.Count, "Incorrect count after remove");
                context.Assert.AreEqual(false, item.MethodCalled == "DataPortal_DeleteSelf", "Should not have deleted new item");
                context.Assert.IsTrue(item.IsNew, "Object should be new after delete");

                context.Assert.Success();
            }
                                                       );
            context.Complete();
        }
示例#5
0
        public void UpdateItemViaListSavedEvent()
        {
            UnitTestContext context = GetContext();

            DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName;
            WcfProxy.DefaultUrl      = cslalighttest.Properties.Resources.RemotePortalUrl;
            ApplicationContext.GlobalContext.Clear();

            RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) =>
            {
                context.Assert.Try(() =>
                {
                    context.Assert.IsNotNull(e.Object);
                    RootSingleItemsList list = e.Object;
                    context.Assert.AreEqual(2, list.Count, "Count should be 2");
                    list.Saved += (o1, e1) =>
                    {
                        context.Assert.IsNull(e1.Error);
                        context.Assert.AreEqual(2, list.Count, "Incorrect count after remove");
                        context.Assert.AreEqual("DataPortal_Update", ((SingleItem)e1.NewObject).MethodCalled, "Object should have been updated");
                        context.Assert.IsFalse(list[0].IsDirty, "Object should not be dirty");
                        context.Assert.Success();
                    };

                    // simulate grid edit
                    SingleItem item     = list[0];
                    IEditableObject obj = (IEditableObject)item;
                    obj.BeginEdit();
                    item.Name = "test";
                    obj.EndEdit();
                });
            });
            context.Complete();
        }
示例#6
0
    public void initRRP()
    {
        ResultRewardPanel.localScale = Vector3.one;
        ResultRewardPanel.gameObject.SetActive(true);
        ResultRewardPanel.GetComponent <CanvasGroup>().alpha = 1;
        SDGameManager.Instance.heroSelectType = SDConstants.HeroSelectType.Altar;
        //构建角色卡牌
        List <Transform> AllTrans = RRPContent.GetComponentsInChildren <Transform>()
                                    .ToList().FindAll(x => x != RRPContent);

        for (int i = 0; i < AllTrans.Count; i++)
        {
            if (i >= RewardHCs.Count)
            {
                AllTrans[i].localScale = Vector3.zero;
                continue;
            }
            AllTrans[i].localScale = Vector3.one;
            Transform s = Instantiate(roleItem, AllTrans[i]) as Transform;
            s.localScale = Vector3.one;
            s.position   = AllTrans[i].position;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.initCalledHero(RewardHCs[i]);
            resultRewards.Add(_s);
        }
        //
        StartCoroutine(IEInitCallingRewards());
    }
示例#7
0
        public void SingleItemHoldsValue()
        {
            {
                SingleItem <MyInt> si = (MyInt)42;
                Assert.Equal((MyInt)42, si.Value);
                Assert.Equal((MyInt)42, (MyInt)si);
            }

            {
                MyInt i = 42;
                SingleItem <MyInt> si = i;
                Assert.Equal(i, si.Value);
                MyInt o = si;
                Assert.Equal(i, o);
            }

            {
                string i = "foo";
                SingleItem <string> si = i;
                Assert.Equal(i, si.Value);
                string o = si;
                Assert.Equal(i, o);
            }

            {
                MyFalseEquatable i = new MyFalseEquatable();
                SingleItem <MyFalseEquatable> si = i;
                Assert.Same(i, si.Value);
                MyFalseEquatable o = si;
                Assert.Same(i, o);
            }
        }
示例#8
0
    public void showEnemyInIllustrate()
    {
        ResetPageWithoutDestroy();
        List <GDEItemData> all = SDDataManager.Instance.GetAllEnemiesPlayerSaw;

        itemCount = all.Count;
        if (itemCount <= 0)
        {
            foreach (SingleItem s in AllItemSlots)
            {
                s.SetSelfAsBg();
            }
        }
        int endNumInVolume = Mathf.Max(0, itemCount - PerPageMaxVolume * pageIndex);
        int startIndex     = PerPageMaxVolume * pageIndex;

        for (int i = 0; i < PerPageMaxVolume; i++)
        {
            if (i >= endNumInVolume)
            {
                AllItemSlots[i].SetSelfAsBg();
                continue;
            }
            else
            {
                SingleItem _s = AllItemSlots[i];
                _s.sourceController = this;
                _s.initEnemy(all[i + startIndex]);
                items.Add(_s);
            }
        }
    }
示例#9
0
    public void ShowHeroesOwnedToBattle()
    {
        ResetPage();

        List <GDEHeroData> heroes = SDDataManager.Instance.PlayerData.herosOwned;

        itemCount = heroes.Count;
        //if (itemCount <= 0) equipSelect.refreshEmptyEquipPanel(true);
        //else equipSelect.refreshEmptyEquipPanel(false);
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.initBattleHero(heroes[i]);
            _s.sourceController = this;
            _s.index            = i;
            if (heroes[i].status == 1)
            {
                _s.isSelected = true;
            }
            else
            {
                _s.isSelected = false;
            }

            items.Add(_s);
        }
    }
示例#10
0
 public bool DeepEquals(VendorItemSocketOverride other)
 {
     return(other != null &&
            SingleItem.DeepEquals(other.SingleItem) &&
            RandomizedOptionsCount == other.RandomizedOptionsCount &&
            SocketType.DeepEquals(other.SocketType));
 }
示例#11
0
        private static void Clear(bool bAll)
        {
            if (!Enabled)
            {
                return;
            }
            int iPwColIndex = GetPwColumnIndex();

            if (iPwColIndex < 0)
            {
                m_lItems.Clear();
            }
            for (int i = m_lItems.Count - 1; i >= 0; i--)
            {
                SingleItem si  = m_lItems[i];
                int        idx = IndexOf(si.Entry);
                if (idx < 0)
                {
                    m_lItems.Remove(si);
                    continue;
                }
                if (!bAll && !si.Hidden)
                {
                    continue;
                }
                EntriesListView.Items[idx].SubItems[iPwColIndex].Text = KeePassLib.PwDefs.HiddenPassword;
                m_lItems.Remove(si);
            }
        }
示例#12
0
        public void SingleItemInvalidAssignmentThrows()
        {
            SingleItem <MyInt>   i1 = (MyInt)4;
            MyFalseEquatableItem i2 = new MyFalseEquatableItem();

            Assert.Throws <ConfigItem.InvalidTypeAssignmentException>(() => i1.Assign(i2));
        }
示例#13
0
        public void SingleItemAssignmentChangesValue()
        {
            SingleItem <MyInt> i1 = (MyInt)4;
            SingleItem <MyInt> i2 = (MyInt)42;

            i1.Assign(i2);
            Assert.Equal <MyInt>(new MyInt(42), i2);
        }
示例#14
0
        public override void Read()
        {
            var itemgroup = new CollectionItem();

            var items = new AreaItems();

            var item = new SingleItem();

            foreach (string s in Strings)
            {
                if (s.StartsWith("// "))
                {
                    continue;
                }

                if (s.StartsWith("//"))
                {
                    items = new AreaItems {
                        Name = s.Replace("//", "")
                    };

                    continue;
                }

                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                if (s.StartsWith("0x"))
                {
                    if (items.Color != System.Windows.Media.Colors.Black)
                    {
                        Items.List.Add(items);
                    }
                    items.Color = ReadColorFromInt(s);
                    itemgroup   = new CollectionItem();
                    Items.List.Add(items);
                    continue;
                }
                itemgroup = new CollectionItem();
                var str = s.Split('/');
                itemgroup.Name = str.Last();
                var s1 = str[0].Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();

                itemgroup.Percent = int.Parse(s1.First());

                s1.Remove(s1.First());

                for (int index = 0; index < s1.Count; index++)
                {
                    DivideEtImpera(index, s1, ref item, itemgroup);
                }

                items.List.Add(itemgroup);
            }
        }
示例#15
0
        public storePlusResponse Put(int itemId, [FromBody] SingleItem value)
        {
            var ret = new storePlusResponse()
            {
                status = "success", itemsInBag = "2"
            };

            return(ret);
        }
示例#16
0
    public void showEmptyItem(SDConstants.ItemType Type)
    {
        Transform s = Instantiate(SItem) as Transform;

        s.transform.SetParent(scrollRect.content);
        s.transform.localScale = Vector3.one;
        s.gameObject.SetActive(true);
        SingleItem _s = s.GetComponent <SingleItem>();

        _s.sourceController = this;
        _s.index            = -1;
        _s.isEmpty          = true;
    }
示例#17
0
        public void SingleItemEqualsCallsItemEquals()
        {
            {
                MyFalseEquatable e = new MyFalseEquatable();
                SingleItem <MyFalseEquatable> si1 = e;
                SingleItem <MyFalseEquatable> si2 = e;
                Assert.False(si1.Equals(si2));
            }

            {
                SingleItem <MyTrueEquatable> si1 = new MyTrueEquatable();
                SingleItem <MyTrueEquatable> si2 = new MyTrueEquatable();
                Assert.True(si1.Equals(si2));
            }
        }
示例#18
0
    public void showOnePosEquipsOwned(EquipPosition pos)
    {
        ResetPageWithoutDestroy();
        //ResetPage();
        List <GDEEquipmentData> allEquips;

        if (currentHeroHashcode > 0 && SDDataManager.Instance.getHeroIdByHashcode
                (currentHeroHashcode) != null)
        {
            string id = SDDataManager.Instance.getHeroIdByHashcode(currentHeroHashcode);
            allEquips = SDDataManager.Instance.GetPosOwnedEquipsByCareer
                            (pos, id, true);
        }
        else
        {
            allEquips = SDDataManager.Instance.getOwnedEquipsByPos(pos, true);
        }

        itemCount = allEquips.Count;
        if (itemCount <= 0)
        {
            foreach (SingleItem s in AllItemSlots)
            {
                s.SetSelfAsBg();
            }
        }
        int endNumInVolume = Mathf.Max(0, itemCount - PerPageMaxVolume * pageIndex);
        int startIndex     = PerPageMaxVolume * pageIndex;

        for (int i = 0; i < PerPageMaxVolume; i++)
        {
            if (i >= endNumInVolume)
            {
                AllItemSlots[i].SetSelfAsBg();
                continue;
            }
            else
            {
                SingleItem _s = AllItemSlots[i];
                _s.sourceController = this;
                _s.initEquip(allEquips[i + startIndex]);
                items.Add(_s);
            }
        }
    }
        public HttpResponseMessage Get(String itemId, String lang = DEFAULT_LANG, String currency = DEFAULT_CURRENCY)
        {
            SingleItem singleItem = null;

            if (itemId == "0688740980202")
            {
                string title = "Micro-patterned oxford shirt";
                if (lang == "he")
                {
                    title = "חולצה מיקרו כותנה";
                }

                singleItem = new SingleItem("0688740980202", title, 25.99, "http://static.zara.net/photos//2015/V/0/2/p/4036/260/403/2/w/1024/4036260403_1_1_1.jpg");
                singleItem.sizes.Add(new SingleItem.ItemSize("s", "S", inbagsStock: "0", availbleStock: "4"));
                singleItem.sizes.Add(new SingleItem.ItemSize("m", "M", inbagsStock: "1", availbleStock: "2"));
                singleItem.sizes.Add(new SingleItem.ItemSize("l", "L", inbagsStock: "2", availbleStock: "5"));
            }
            else if (itemId == "0503911180002")
            {
                singleItem = new SingleItem("0503911180002", "Faux leather bomber jacket", 39.99, "http://static.zara.net/photos//2015/V/0/2/p/0706/405/700/2/w/1024/0706405700_1_1_1.jpg");
                singleItem.sizes.Add(new SingleItem.ItemSize("s", "S", inbagsStock: "4", availbleStock: "2"));
                singleItem.sizes.Add(new SingleItem.ItemSize("m", "M", inbagsStock: "1", availbleStock: "7"));
                singleItem.sizes.Add(new SingleItem.ItemSize("l", "L", inbagsStock: "0", availbleStock: "5"));
            }

            var httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, singleItem, JsonMediaTypeFormatter.DefaultMediaType);

            var objectContent = httpResponseMessage.Content as ObjectContent;

            if (objectContent != null)
            {
                var jsonMediaTypeFormatter = new JsonMediaTypeFormatter
                {
                    SerializerSettings =
                    {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    }
                };
                httpResponseMessage.Content = new ObjectContent(objectContent.ObjectType, objectContent.Value, jsonMediaTypeFormatter);
            }

            return(httpResponseMessage);
        }
示例#20
0
    public void refreshPage()
    {
        Page.CurrentType = SDConstants.ItemType.Rune;
        Page.Select_None();
        List <int> hcs = ComposeMaterialSlots.Select(x => x.hashcode).ToList();

        hcs = hcs.FindAll(x => x > 0);
        for (int i = 0; i < Page.itemCount; i++)
        {
            SingleItem s = Page.items[i];
            if (hcs.Exists(x => x == s.itemHashcode) ||
                s.itemHashcode == currentRuneHashcode)
            {
                s.isSelected = true;
            }
        }

        refreshComposeCondition();
    }
示例#21
0
    public void showRuneOwned()
    {
        ResetPage();
        List <GDERuneData> runes = SDDataManager.Instance.getAllRunesOwned;

        itemCount = runes.Count;
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initRuneInPage(runes[i]);
            items.Add(_s);
        }
    }
示例#22
0
        public Guid unstack(Guid ent, Guid?guid = null)
        {
            if (!this.contents.ContainsKey(ent))
            {
                throw new ArgumentOutOfRangeException(nameof(ent));
            }
            ItemStack stack = this.contents[ent] as ItemStack;

            if ((stack is null) || (stack.count != 1))
            {
                throw new ArgumentOutOfRangeException(nameof(ent));
            }

            SingleItem new_item = new SingleItem(stack.item, stack.unidentified >= 1);
            Guid       result   = this.add(new_item, guid);

            this.remove(ent);
            return(result);
        }
示例#23
0
    public void showAllDropItems()
    {
        GameController GameC = GetComponentInParent <GameController>();

        itemCount = GameC.allDropsGet.Count;
        for (int i = 0; i < itemCount; i++)
        {
            GDEItemData M = GameC.allDropsGet[i];
            Transform   s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initDrop(M);
            items.Add(_s);
        }
    }
示例#24
0
    public void showConsumableOwned(bool showTaken = false)
    {
        ResetPage();
        List <GDEItemData> props = SDDataManager.Instance.PlayerData.consumables;

        itemCount = props.Count;
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initConsumable(props[i], showTaken);
            items.Add(_s);
        }
    }
示例#25
0
    public void showAllEquipsOwned()
    {
        List <GDEEquipmentData> allEquips = SDDataManager.Instance.getAllOwnedEquips();

        //int heroHashcode = SDDataManager.Instance.getherohash
        itemCount = allEquips.Count;
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            //_s.initEquip(allEquips[i].equipId, allEquips[i].upLv);
            _s.sourceController = this;
            _s.index            = i;
            _s.initEquip(allEquips[i]);
            items.Add(_s);
        }
    }
示例#26
0
    public void ShowHeroesOwned()
    {
        ResetPage();
        List <GDEHeroData> heroes = SDDataManager.Instance.PlayerData.herosOwned;

        //int index = 0;
        itemCount = heroes.Count;
        //int maxHeroNum = SDConstants.EquipNumPerPage;
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initHero(heroes[i]);
            items.Add(_s);
        }
    }
示例#27
0
        private static bool Remove(KeePassLib.PwEntry pe)
        {
            if (!Enabled)
            {
                return(false);
            }
            int        idx         = IndexOf(pe);
            int        iPwColIndex = GetPwColumnIndex();
            SingleItem si          = m_lItems.Find(x => x.Entry.Uuid.Equals(pe.Uuid));

            if (si == null)
            {
                return(true);
            }
            m_lItems.Remove(si);
            if (idx >= 0 && iPwColIndex >= 0)
            {
                EntriesListView.Items[idx].SubItems[iPwColIndex].Text = KeePassLib.PwDefs.HiddenPassword;
            }
            return(true);
        }
示例#28
0
    public void showNPCOwned(bool cantShowInBag = false)
    {
        ResetPage();
        List <GDENPCData> baseall = SDDataManager.Instance.PlayerData.NPCList;

        if (!cantShowInBag)
        {
            baseall = baseall.FindAll(x => x.ShowInBag);
        }
        itemCount = baseall.Count;
        for (int i = 0; i < itemCount; i++)
        {
            Transform s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;

            items.Add(_s);
        }
    }
示例#29
0
        private void DivideEtImpera(int stringCounter, List <String> list, ref SingleItem item, CollectionItem itemGroup)
        {
            switch (stringCounter % 5)
            {
            case 0:
            {
                item.Id = Convert.ToInt16(list[stringCounter], 16);
                break;
            }

            case 1:
            {
                item.Z = sbyte.Parse(list[stringCounter]);
                break;
            }

            case 2:
            {
                item.Hue = Convert.ToInt16(list[stringCounter], 16);
                break;
            }

            case 3:
            {
                item.X = int.Parse(list[stringCounter]);
                break;
            }

            case 4:
            {
                item.Y = int.Parse(list[stringCounter]);
                itemGroup.List.Add(item);
                item = new SingleItem();
                break;
            }

            default:
                break;
            }
        }
示例#30
0
    public void showGoddessOwned(bool onlyOwned = true)
    {
        ResetPage();
        List <GDEgoddessData> goddesses = new List <GDEgoddessData>();

        if (onlyOwned)
        {
            goddesses = SDDataManager.Instance.PlayerData.goddessOwned;
            itemCount = goddesses.Count;
            for (int i = 0; i < itemCount; i++)
            {
                Transform s = Instantiate(SItem) as Transform;
                s.transform.SetParent(scrollRect.content);
                s.transform.localScale = Vector3.one;
                s.gameObject.SetActive(true);
                SingleItem _s = s.GetComponent <SingleItem>();
                _s.sourceController = this;
                _s.index            = i;
                _s.initGoddess(goddesses[i]);
                items.Add(_s);
            }
        }
    }
示例#31
0
        public void TestCopyToZeroLengthArray()
        {
            SingleItem<string> b = new SingleItem<string>("foo");

            try
            {
                b.CopyTo(new string[0], 0);
                Assert.Fail("CopyTo() shouldn't copy to an invalid arrayIndex");
            }
            catch (ArgumentException) { /* expected result */ }
        }
示例#32
0
 public void TestIteration()
 {
     SingleItem<string> b = new SingleItem<string>("foo");
     int count = 0;
     foreach (string s in b)
     {
         count++;
         Assert.AreEqual("foo", s);
     }
     Assert.AreEqual(1, count);
 }
示例#33
0
        public void TestNewSingleItem()
        {
            SingleItem<string> b = new SingleItem<string>("foo");
            Assert.AreEqual(1, b.Count);
            Assert.IsTrue(b.IsReadOnly);
            Assert.AreEqual(1, b.Count);
            Assert.IsTrue(b.Contains("foo"));
            Assert.IsFalse(b.Contains("bar"));

            Assert.IsFalse(b.Remove("bar"));
            Assert.AreEqual(1, b.Count);

            try
            {
                b.Add("bar");
                Assert.Fail("SingleItem can only hold a single item");
            }
            catch (NotSupportedException)
            {
            }

            try
            {
                b.Remove("foo");
            }
            catch (NotSupportedException)
            {
                Assert.Fail("SingleItem should allow the item to be removed");
            }
            Assert.AreEqual(0, b.Count);
            try
            {
                string foo = b[0];
                Assert.Fail("SingleItem no longer has anything");
            }
            catch (ArgumentOutOfRangeException) { /* expected */ }
            try
            {
                b.Add("bar");
            }
            catch (NotSupportedException)
            {
                Assert.Fail("SingleItem should be able to add to an empty list");
            }
            Assert.AreEqual(1, b.Count);
            Assert.IsFalse(b.Contains("foo"));
            Assert.IsTrue(b.Contains("bar"));
        }