Esempio n. 1
0
        public void RequireFilter()
        {
            var particle = new CompositeParticle(ParticleType.Sequence, 1, 1, requireFilter: true)
            {
                new CompositeParticle(ParticleType.Group, 1, 1),
                new CompositeParticle(ParticleType.Group, 1, 2, version: FileFormatVersions.Office2010),
            };

            var built2007 = Assert.IsType <CompositeParticle>(particle.Build(FileFormatVersions.Office2007));

            Assert.NotSame(particle, built2007);

            var result2007 = Assert.Single(built2007.ChildrenParticles);

            Assert.Equal(ParticleType.Group, result2007.ParticleType);
            Assert.Equal(1, result2007.MaxOccurs);

            var built2010 = Assert.IsType <CompositeParticle>(particle.Build(FileFormatVersions.Office2010));

            Assert.NotSame(particle, built2010);

            var result2010 = Assert.Single(built2010.ChildrenParticles);

            Assert.Equal(ParticleType.Group, result2010.ParticleType);
            Assert.Equal(2, result2010.MaxOccurs);
        }
Esempio n. 2
0
        public void CompositeSequenceMultipleVersion()
        {
            var particle = new CompositeParticle(ParticleType.Sequence, 1, 1)
            {
                new ElementParticle(typeof(ParticleTests), 1, 1),
                new ElementParticle(typeof(ParticleTests), 1, 1, version: FileFormatVersions.Office2010),
                new NsAnyParticle(0, 1, 1),
            };

            var built2007 = Assert.IsType <CompositeParticle>(particle.Build(FileFormatVersions.Office2007));

            Assert.NotSame(particle, built2007);

            Assert.Collection(
                built2007.ChildrenParticles,
                p => Assert.Same(p, particle.ChildrenParticles[0]),
                p => Assert.Same(p, particle.ChildrenParticles[2]));

            var built2010 = Assert.IsType <CompositeParticle>(particle.Build(FileFormatVersions.Office2010));

            Assert.NotSame(particle, built2010);

            Assert.Collection(
                built2010.ChildrenParticles,
                p => Assert.Same(p, particle.ChildrenParticles[1]),
                p => Assert.Same(p, particle.ChildrenParticles[2]));
        }
Esempio n. 3
0
        public void CompositeSequenceNoVersion(FileFormatVersions version)
        {
            var particle = new CompositeParticle(ParticleType.Sequence, 1, 1)
            {
                new ElementParticle(typeof(ParticleTests), 1, 1),
                new AnyParticle(1, 1),
                new NsAnyParticle(0, 1, 1),
            };

            var built = Assert.IsType <CompositeParticle>(particle.Build(version));

            Assert.NotSame(particle, built);

            Assert.Collection(built.ChildrenParticles,
                              p => Assert.Same(p, particle.ChildrenParticles[0]),
                              p => Assert.Same(p, particle.ChildrenParticles[1]),
                              p => Assert.Same(p, particle.ChildrenParticles[2]));
        }