public async void EntityInvoker_TestSaveAssemblyToInvalidPath()
        {
            Definition definitonAttribute = new Definition()
            {
                Id = "TestId"
            };

            string         assemblyPath = string.Empty;
            EntityMetadata metadata     = ScriptTestDataHelper.GetRandomMetadata();

            metadata.ScriptText = await ScriptTestDataHelper.GetDetectorScript(definitonAttribute);

            using (EntityInvoker invoker = new EntityInvoker(metadata, ScriptHelper.GetFrameworkReferences(), ScriptHelper.GetFrameworkImports()))
            {
                await invoker.InitializeEntryPointAsync();

                await Assert.ThrowsAsync <ArgumentNullException>(async() =>
                {
                    await invoker.SaveAssemblyToDiskAsync(assemblyPath);
                });
            }
        }
        public async void EntityInvoker_TestSaveAssemblyToDisk()
        {
            Definition definitonAttribute = new Definition()
            {
                Id = "TestId"
            };

            string         assemblyPath = $@"{Directory.GetCurrentDirectory()}\{Guid.NewGuid().ToString()}";
            EntityMetadata metadata     = ScriptTestDataHelper.GetRandomMetadata();

            metadata.ScriptText = await ScriptTestDataHelper.GetDetectorScript(definitonAttribute);

            using (EntityInvoker invoker = new EntityInvoker(metadata, ScriptHelper.GetFrameworkReferences(), ScriptHelper.GetFrameworkImports()))
            {
                await invoker.InitializeEntryPointAsync();

                await invoker.SaveAssemblyToDiskAsync(assemblyPath);

                Assert.True(File.Exists($"{assemblyPath}.dll"));
                Assert.True(File.Exists($"{assemblyPath}.pdb"));
            }
        }
        public async void EntityInvoker_TestInitializationUsingAssembly()
        {
            // First Create and Save a assembly for test purposes.
            Definition definitonAttribute = new Definition()
            {
                Id = "TestId"
            };

            string         assemblyPath = $@"{Directory.GetCurrentDirectory()}/{Guid.NewGuid().ToString()}";
            EntityMetadata metadata     = ScriptTestDataHelper.GetRandomMetadata();

            metadata.ScriptText = await ScriptTestDataHelper.GetDetectorScript(definitonAttribute);

            using (EntityInvoker invoker = new EntityInvoker(metadata, ScriptHelper.GetFrameworkReferences(), ScriptHelper.GetFrameworkImports()))
            {
                await invoker.InitializeEntryPointAsync();

                await invoker.SaveAssemblyToDiskAsync(assemblyPath);

                Assert.True(File.Exists($"{assemblyPath}.dll"));
                Assert.True(File.Exists($"{assemblyPath}.pdb"));
            }

            // Now test initializing Entry Point of Invoker using assembly
            Assembly asm = Assembly.LoadFrom($"{assemblyPath}.dll");

            using (EntityInvoker invoker = new EntityInvoker(metadata))
            {
                Exception ex = Record.Exception(() =>
                {
                    invoker.InitializeEntryPoint(asm);
                });

                Assert.Null(ex);
                Assert.True(invoker.IsCompilationSuccessful);
                Assert.Equal(definitonAttribute.Id, invoker.EntryPointDefinitionAttribute.Id);
            }
        }