예제 #1
0
        public void TestEmptyRegistry()
        {
            POIFSReaderRegistry registry = new POIFSReaderRegistry();

            for (int i = 0; i < paths.Length; i++)
            {
                for (int j = 0; j < names.Length; j++)
                {
                    IEnumerator listeners = registry.GetListeners(paths[i], names[j]);
                    Assert.IsTrue(!listeners.MoveNext());
                }
            }
        }
예제 #2
0
        public void TestMixedRegistrationOperations()
        {
            POIFSReaderRegistry registry = new POIFSReaderRegistry();

            for (int i = 0; i < listeners.Length; i++)
            {
                for (int j = 0; j < paths.Length; j++)
                {
                    for (int k = 0; k < names.Length; k++)
                    {
                        if ((i != j) && (j != k))
                        {
                            registry.RegisterListener(listeners[i], paths[j], names[k]);
                        }
                    }
                }
            }
            for (int k = 0; k < paths.Length; k++)
            {
                for (int n = 0; n < names.Length; n++)
                {
                    IEnumerator listeners = registry.GetListeners(paths[k], names[n]);

                    if (k == n)
                    {
                        Assert.IsTrue(!listeners.MoveNext());
                    }
                    else
                    {
                        ArrayList registeredListeners = new ArrayList();

                        while (listeners.MoveNext())
                        {
                            registeredListeners.Add(listeners.Current);
                        }
                        Assert.AreEqual(this.listeners.Length - 1, registeredListeners.Count);
                        for (int j = 0; j < this.listeners.Length; j++)
                        {
                            if (j == k)
                            {
                                Assert.IsTrue(!registeredListeners.Contains(this.listeners[j]));
                            }
                            else
                            {
                                Assert.IsTrue(registeredListeners.Contains(this.listeners[j]));
                            }
                        }
                    }
                }
            }
            for (int j = 0; j < listeners.Length; j++)
            {
                registry.RegisterListener(listeners[j]);
            }

            for (int k = 0; k < paths.Length; k++)
            {
                for (int n = 0; n < names.Length; n++)
                {
                    IEnumerator listeners = registry.GetListeners(paths[k], names[n]);

                    ArrayList registeredListeners = new ArrayList();

                    while (listeners.MoveNext())
                    {
                        registeredListeners.Add(listeners.Current);
                    }

                    Assert.AreEqual(this.listeners.Length, registeredListeners.Count);

                    for (int j = 0; j < this.listeners.Length; j++)
                    {
                        Assert.IsTrue(registeredListeners.Contains(this.listeners[j]));
                    }
                }
            }
        }