예제 #1
0
        public void DoesContain()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);
            Assert.True(plugins.Contains(ap));
        }
예제 #2
0
        public void CanAdd()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            Assert.True(plugins.Add(ap) == 0);
            Assert.True(plugins.Count > 0);
            Assert.True(plugins.Add(ap) == -1);
        }
예제 #3
0
        public void CanGetIndex()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            Assert.True(plugins.IndexOf(ap) == 0);
        }
예제 #4
0
        public void CanGetFromIndexer()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            Assert.True(plugins[0].Equals(ap));
        }
예제 #5
0
        public void CanCopyToArray()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            AvailablePlugin[] pluginArray = new AvailablePlugin[plugins.Count];
            plugins.CopyTo(pluginArray, 0);

            Assert.True(pluginArray.Length == 1);
        }
예제 #6
0
        public void CanTestNullOrEmpty()
        {
            Assert.True(AvailablePluginCollection.IsNullOrEmpty(null));

            var plugins = new AvailablePluginCollection();

            Assert.True(AvailablePluginCollection.IsNullOrEmpty(plugins));

            var tp = new TestPlugin();
            var ap = new AvailablePlugin(tp, this.AssemblyPath);

            plugins.Add(ap);

            Assert.False(AvailablePluginCollection.IsNullOrEmpty(plugins));
        }
예제 #7
0
        public void CanRemove()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            // So we should have 1 plugin in the collection.
            Assert.True(plugins.Count == 1);

            // Now remove it and verify that the count is zero.
            plugins.Remove(ap);
            Assert.True(plugins.Count == 0);
        }
예제 #8
0
        public void CanFind()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            var result = plugins.Find(ap.Instance.Name);

            Assert.NotNull(result);

            result = plugins.Find(ap.AssemblyPath);
            Assert.NotNull(result);
            Assert.True(result.Equals(ap));

            plugins.Remove(ap);
            result = plugins.Find(ap.Instance.Name);
            Assert.Null(result);
        }
예제 #9
0
        public void CanInsert()
        {
            var tp      = new TestPlugin();
            var ap      = new AvailablePlugin(tp, this.AssemblyPath);
            var plugins = new AvailablePluginCollection();

            plugins.Add(ap);

            var apPath2 = Path.Combine(Path.GetDirectoryName(this.AssemblyPath), Guid.NewGuid().ToString() + ".dll");
            var ap2     = new AvailablePlugin(tp, apPath2);

            plugins.Add(ap2);

            var apPath3 = Path.Combine(Path.GetDirectoryName(this.AssemblyPath), Guid.NewGuid().ToString() + ".dll");
            var ap3     = new AvailablePlugin(tp, apPath3);

            plugins.Insert(1, ap3);

            // At this point, ap should be at index 0. ap2 should be at index 2, and ap3 should be at index 1.
            Assert.True(plugins[0].Equals(ap));
            Assert.True(plugins[1].Equals(ap3));
            Assert.True(plugins[2].Equals(ap2));
        }
예제 #10
0
        public void CanConstruct()
        {
            var plugins = new AvailablePluginCollection();

            Assert.True(plugins.Count == 0);
        }