Exemplo n.º 1
0
        public void List_Clear()
        {
            var lst = new EventedList <string, string>("CONTEXT", false);

            var first = true;

            lst.GetReadOnlyEvent = (_) => false;

            lst.Add("a");
            lst.Add("b");
            lst.Add("c");

            Aver.AreEqual(3, lst.Count);

            lst.ChangeEvent = (l, ct, p, idx, v) =>
            {
                Aver.AreObjectsEqual(EventedList <string, string> .ChangeType.Clear, ct);
                Aver.AreObjectsEqual(first ? EventPhase.Before : EventPhase.After, p);
                Aver.AreEqual(-1, idx);
                Aver.AreEqual(null, v);
                first = false;
            };

            lst.Clear();
            Aver.AreEqual(0, lst.Count);
        }
Exemplo n.º 2
0
        public void List_Clear()
        {
            var lst = new EventedList<string, string>("CONTEXT", false);

              var first = true;
              lst.GetReadOnlyEvent = (_) => false;

              lst.Add("a");
              lst.Add("b");
              lst.Add("c");

              Assert.AreEqual(3, lst.Count);

              lst.ChangeEvent = (l, ct, p, idx, v) =>
                            {
                              Assert.AreEqual( EventedList<string, string>.ChangeType.Clear, ct);
                              Assert.AreEqual( first ? EventPhase.Before : EventPhase.After, p);
                              Assert.AreEqual( -1, idx);
                              Assert.AreEqual( null, v);
                              first = false;
                            };

              lst.Clear();
              Assert.AreEqual( 0, lst.Count);
        }
Exemplo n.º 3
0
        public void ClearTest()
        {
            var l = new EventedList <EClass>();

            l.Add(new EClass());
            Assert.That(l.Count, Is.EqualTo(1));
            l.Clear();
            Assert.That(l.Count, Is.EqualTo(0));
        }
Exemplo n.º 4
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null)
            {
                //0 get very root
                node = App.ConfigRoot[SysConsts.CONFIG_WAVE_SECTION];
                if (!node.Exists)
                {
                    return;
                }

                //1 try to find the server with the same name as this instance
                var snode = node.Children.FirstOrDefault(cn => cn.IsSameName(CONFIG_SERVER_SECTION) && cn.IsSameNameAttr(Name));

                //2 try to find a server without a name
                if (snode == null)
                {
                    snode = node.Children.FirstOrDefault(cn => cn.IsSameName(CONFIG_SERVER_SECTION) && cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value.IsNullOrWhiteSpace());
                }

                if (snode == null)
                {
                    return;
                }
                node = snode;
            }


            ConfigAttribute.Apply(this, node);

            m_Prefixes.Clear();
            foreach (var name in node.Children
                     .Where(c => c.IsSameName(CONFIG_PREFIX_SECTION))
                     .Select(c => c.AttrByName(Configuration.CONFIG_NAME_ATTR).Value)
                     .Where(n => n.IsNotNullOrWhiteSpace()))
            {
                m_Prefixes.Add(name);
            }

            var nGate = node[CONFIG_GATE_SECTION];

            if (nGate.Exists)
            {
                m_Gate = FactoryUtils.MakeAndConfigure <INetGateImplementation>(nGate, typeof(NetGate), args: new object[] { this });
            }

            var nDispatcher = node[CONFIG_DISPATCHER_SECTION];

            if (nDispatcher.Exists)
            {
                m_Dispatcher = FactoryUtils.MakeAndConfigure <WorkDispatcher>(nDispatcher, typeof(WorkDispatcher), args: new object[] { this });
            }

            ErrorFilter.ConfigureMatches(node[CONFIG_DEFAULT_ERROR_HANDLER_SECTION], m_ErrorShowDumpMatches, m_ErrorLogMatches, null, GetType().FullName);
        }
Exemplo n.º 5
0
        public void TestClear()
        {
            Init();

            m_uut.AddRange(new string[] { "Bob", "Mary", "Sue" });
            m_uut.Clear();

            Assert.IsTrue(m_uut.Count == 0);
            Assert.IsTrue(m_responses.Equals("m_uut_AboutToAddItems System.String[] | m_uut_AddedItems System.String[] | m_uut_ContentsChanged | m_uut_ContentsChanged | "));
            Console.WriteLine(m_responses);
        }