public void Load_Test() { var sdkDir = Path.GetDirectoryName(typeof(SdkStreamManager).Assembly.Location); var sdkStreamManager = new SdkStreamManager(sdkDir); var loader = new ContractCodeLoadContext(sdkStreamManager); var code = File.ReadAllBytes(typeof(TestContract).Assembly.Location); using (var stream = new MemoryStream(code)) { var assembly = loader.LoadFromStream(stream); Activator.CreateInstance(assembly.GetType("AElf.Runtime.CSharp.Tests.TestContract.TestContract")); assembly.FullName.ShouldBe( "AElf.Runtime.CSharp.Tests.TestContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); loader.Assemblies.Count().ShouldBe(2); loader.Assemblies.ShouldContain(a => a.FullName == "AElf.Runtime.CSharp.Tests.TestContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); loader.Assemblies.ShouldContain(a => a.FullName == "AElf.Sdk.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); } loader.Unload(); }
public void GetStream_SdkPathNotExist_Test() { var sdkStreamManager = new SdkStreamManager("/NotExist/"); var assemblyName = new AssemblyName("AElf.Runtime.CSharp.Core"); using (var stream = sdkStreamManager.GetStream(assemblyName)) { CheckGetStreamResult(stream); } // Get stream from cache using (var stream = sdkStreamManager.GetStream(assemblyName)) { CheckGetStreamResult(stream); } }
public void GetStream_SdkPathExist_Test() { var sdkDir = Path.GetDirectoryName(typeof(SdkStreamManager).Assembly.Location); var sdkStreamManager = new SdkStreamManager(sdkDir); var assemblyName = new AssemblyName("AElf.Runtime.CSharp.Core"); using (var stream = sdkStreamManager.GetStream(assemblyName)) { CheckGetStreamResult(stream); } // Get stream from cache using (var stream = sdkStreamManager.GetStream(assemblyName)) { CheckGetStreamResult(stream); } }