示例#1
0
        public void TestGenerateAssembly_WithPackerOption_OptionsAreAsSpecified()
        {
            var name     = new AssemblyName(MethodBase.GetCurrentMethod().Name);
            var filePath = Path.GetFullPath("." + Path.DirectorySeparatorChar + name.Name + ".dll");
            var result   =
                SerializerGenerator.GenerateAssembly(
                    new SerializerAssemblyGenerationConfiguration {
                AssemblyName = name
            },
                    typeof(GeneratorTestObject)
                    );

            // Assert is not polluted.
            Assert.That(SerializationContext.Default.ContainsSerializer(typeof(GeneratorTestObject)), Is.False);
            Assert.That(result, Is.EqualTo(filePath));

            try
            {
                TestOnWorkerAppDomain(
                    filePath,
                    PackerCompatibilityOptions.None,
                    new byte[] { ( byte )'A' },
                    new byte[] { MessagePackCode.MinimumFixedArray + 1, MessagePackCode.Bin8, 1, ( byte )'A' },
                    TestType.GeneratorTestObject
                    );
            }
            finally
            {
                File.Delete(filePath);
            }
        }
示例#2
0
        public void TestGenerateAssembly_WithDirectory_DllIsGeneratedOnSpecifiedDirectory()
        {
            var name      = new AssemblyName(MethodBase.GetCurrentMethod().Name);
            var directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var filePath  = Path.Combine(directory, name.Name + ".dll");
            var result    =
                SerializerGenerator.GenerateAssembly(
                    new SerializerAssemblyGenerationConfiguration {
                AssemblyName = name, OutputDirectory = directory
            },
                    typeof(GeneratorTestObject)
                    );

            // Assert is not polluted.
            Assert.That(SerializationContext.Default.ContainsSerializer(typeof(GeneratorTestObject)), Is.False);
            Assert.That(result, Is.EqualTo(filePath));

            try
            {
                TestOnWorkerAppDomain(
                    filePath,
                    PackerCompatibilityOptions.Classic,
                    new byte[] { ( byte )'A' },
                    new byte[] { MessagePackCode.MinimumFixedArray + 1, MessagePackCode.MinimumFixedRaw + 1, ( byte )'A' },
                    TestType.GeneratorTestObject
                    );
            }
            finally
            {
                Directory.Delete(directory, true);
            }
        }