public void GeneratedAssemblyBuilderWithAssemblyInfoSucceeds()
        {
            var builder = new GeneratedAssemblyBuilder();

            builder.WithAssemblyName(Guid.NewGuid().ToString("N"))
            .WithAssemblyInfo("company", "productName", "1.0.0.0", "description")
            .InCurrentDirectory()
            .WithClass("TestClassActivator").InNamespace("PRI.Activators")
            .ImplementsInterface <ISimple>()
            .WithMethod("SimpleMethod")
            .WithReturnType(typeof(void))
            .WithInstruction(new NullaryInstruction(OpCodes.Ret))
            .CommitMethod()
            .WithMethod("Create")
            .WithReturnType(typeof(Customer))
            .WithInstruction(new UnaryInstruction(OpCodes.Newobj, typeof(Customer).GetConstructor(Type.EmptyTypes)))
            .WithLocal(typeof(Customer))
            .WithInstruction(new NullaryInstruction(OpCodes.Stloc_0))
            .WithInstruction(new NullaryInstruction(OpCodes.Ldloc_0))
            .WithInstruction(new NullaryInstruction(OpCodes.Ret))
            .WithParameter()
            .WithType(typeof(int))
            .CommitParameter()
            .CommitMethod()
            .CommitType()
            .SaveAssembly();
            var results = new List <ValidationResult>();

            builder.TryValidate(results);
            var filePath = Path.Combine(builder.Directory, builder.Name + ".dll");

            Assert.True(File.Exists(filePath));
            File.Delete(filePath);
        }
        public void GeneratedAssemblyBuilderTypeInRootNamespaceSucceeds()
        {
            /*builder.WithAssemblyName(.WithUniqueName)
             * .InDirectory
             * .WithAssemblyInfo
             * .WithClass(name)
             *  .Public
             *  .InterfaceImplementations.Add
             *  .BaseClass
             */
            var builder = new GeneratedAssemblyBuilder();

            builder.WithAssemblyName(Guid.NewGuid().ToString("N"))
            .InCurrentDirectory()
            .WithClass("TestClassActivator")
            .WithMethod("Create")
            .WithReturnType(typeof(Customer))
            .WithInstruction(new UnaryInstruction(OpCodes.Newobj, typeof(Customer).GetConstructor(Type.EmptyTypes)))
            .WithLocal(typeof(Customer))
            .WithInstruction(new NullaryInstruction(OpCodes.Stloc_0))
            .WithInstruction(new NullaryInstruction(OpCodes.Ldloc_0))
            .WithInstruction(new NullaryInstruction(OpCodes.Ret))
            .WithParameter("number")
            .WithType(typeof(int))
            .CommitParameter()
            .CommitMethod()
            .CommitType().SaveAssembly();
            var results = new List <ValidationResult>();

            builder.TryValidate(results);
            var filePath = Path.Combine(builder.Directory, builder.Name + ".dll");

            Assert.True(File.Exists(filePath));
            File.Delete(filePath);
        }
        public void TryValidateWithNullListThrows()
        {
            var builder = new GeneratedAssemblyBuilder();

            Assert.Throws <ArgumentNullException>(() => builder.TryValidate(null));
        }