コード例 #1
0
        public void TestPluginRequirementCollectionUpdate()
        {             

            bool updated = false;
            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();
            Guid guid3 = Guid.NewGuid();

            IPluginRequirementCollection reqs = new PluginRequirementCollection( );
            reqs.Changed += ( o, e ) =>  {if (e.Action == CK.Core.ChangeStatus.Update)
                                                        updated = true;
                                                    };

            PluginRequirement req = reqs.AddOrSet( guid1, RunningRequirement.MustExistAndRun );
            Assert.That( reqs.Count == 1 );
            //Assert.That( (req.Source == reqs.Source) && (reqs.Source == ctx) );

            PluginRequirement req1 = reqs.AddOrSet( guid2, RunningRequirement.MustExistAndRun );
            Assert.That( reqs.Count == 2 );

            PluginRequirement req2 =  reqs.AddOrSet( guid3, RunningRequirement.MustExistAndRun );
            Assert.That( reqs.Count == 3 );

            Assert.That( reqs.Contains( req2 ) && reqs.Contains( req1 ) && reqs.Contains( req ) );

            PluginRequirement req3 =  reqs.AddOrSet( guid3, RunningRequirement.Optional );

            Assert.That( updated );
            Assert.That( req2 == req3 );
            Assert.That( reqs.Count == 3 );
        }
コード例 #2
0
        public void TestPluginRequirementCollectionEnumerable()
        {
            Guid guid0 = Guid.NewGuid();
            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();

            IPluginRequirementCollection reqs = new PluginRequirementCollection( );

            PluginRequirement req0 = reqs.AddOrSet( guid0, RunningRequirement.MustExistAndRun );
            Assert.That( reqs.Count == 1 );

            PluginRequirement req1 = reqs.AddOrSet( guid1, RunningRequirement.Optional );
            Assert.That( reqs.Count == 2 );

            PluginRequirement req2 =  reqs.AddOrSet( guid2, RunningRequirement.OptionalTryStart );
            Assert.That( reqs.Count == 3 );

            Assert.That( reqs.Contains( req2 ) && reqs.Contains( req1 ) && reqs.Contains( req0 ) );

            reqs.Remove( guid2 );

            Assert.That( reqs.Count == 2 );
            Assert.That( !reqs.Contains( req2 ) );

            int passed = 0;
            foreach( PluginRequirement o in reqs )
            {
                if( o.PluginId == guid0 )
                {
                    Assert.That( o.Requirement == RunningRequirement.MustExistAndRun );
                    passed++;
                }
                if( o.PluginId == guid1 )
                {
                    Assert.That( o.Requirement == RunningRequirement.Optional );
                    passed++;
                }
            }
            Assert.That( passed, Is.EqualTo( 2 ) );

            reqs.Clear();

            Assert.That( reqs.Count == 0 );
            Assert.That( ((PluginRequirement)req0).Holder == null );
            Assert.That( ((PluginRequirement)req1).Holder == null );
            Assert.That( ((PluginRequirement)req2).Holder == null );

            passed = 0;
            foreach( PluginRequirement o in reqs )
            {
                passed++;
            }
            Assert.That( passed == 0 );
        }