コード例 #1
0
        public void Add()
        {
            AssemblyCache builder = new AssemblyCache();

            Assembly assembly1 = Assembly.GetExecutingAssembly();
            Assembly assembly2 = typeof(FactAttribute).Assembly;

            builder.AddAssembly(assembly1);
            Assert.Throws <ArgumentNullException>(() => builder.AddAssembly(null));

            builder.AddAssemblies(new Assembly[] { assembly1, assembly2 });
            Assert.Throws <ArgumentNullException>(() => builder.AddAssemblies(null));
            Assert.Throws <ArgumentException>(() => builder.AddAssemblies(new Assembly[] { assembly1, null }));

            builder.AddFile(assembly1.Location);
            Assert.Throws <ArgumentNullException>(() => builder.AddFile(null));
            Assert.Throws <ArgumentException>(() => builder.AddFile(""));
            Assert.Throws <ArgumentException>(() => builder.AddFile(" "));

            builder.AddFiles(new string[] { assembly1.Location, assembly2.Location });
            Assert.Throws <ArgumentNullException>(() => builder.AddFiles(null));
            Assert.Throws <ArgumentException>(() => builder.AddFiles(new string[] { assembly1.Location, null }));
            Assert.Throws <ArgumentException>(() => builder.AddFiles(new string[] { "", assembly1.Location }));
            Assert.Throws <ArgumentException>(() => builder.AddFiles(new string[] { "  ", assembly1.Location }));
        }
コード例 #2
0
        public void Sequence()
        {
            Assembly assembly1 = Assembly.GetExecutingAssembly();
            Assembly assembly2 = typeof(FactAttribute).Assembly;
            IEnumerable <Assembly> sequence12 = new Assembly[] { assembly1, assembly2 };
            IEnumerable <Assembly> sequence21 = new Assembly[] { assembly2, assembly1 };

            var sequence1 = new AssemblyCache();

            sequence1.AddAssembly(assembly1);
            sequence1.AddAssembly(assembly2);
            sequence1.AddFile(assembly2.Location);
            sequence1.AddFile(assembly1.Location);

            Assert.True(sequence1.SequenceEqual(sequence12));
            Assert.True(sequence1.SequenceEqual(sequence12));

            var sequence2 = new AssemblyCache();

            sequence2.AddAssemblies(sequence21);
            sequence2.AddAssemblies(sequence12);

            Assert.True(sequence2.SequenceEqual(sequence21));
            Assert.True(sequence2.SequenceEqual(sequence21));

            var sequence3 = new AssemblyCache();

            sequence3.AddFile(assembly1.Location);
            sequence3.AddFile(assembly2.Location);
            sequence3.AddAssembly(assembly1);
            sequence3.AddAssembly(assembly2);

            Assert.True(sequence3.SequenceEqual(sequence12));
            Assert.True(sequence3.SequenceEqual(sequence12));

            var sequence4 = new AssemblyCache();

            sequence4.AddFile(assembly2.Location);
            sequence4.AddAssembly(assembly1);
            sequence4.AddFile(assembly1.Location);
            sequence4.AddAssembly(assembly2);

            Assert.True(sequence4.SequenceEqual(sequence21));
            Assert.True(sequence4.SequenceEqual(sequence21));
        }