protected override void SetupTestParamters() { applicationName = "ACM"; simulationName = "Hybrid"; jobId = 1; process = new InMemoryProcess(); using (var fstream = File.Open(@"models\BFBv6_3_new.json", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "configuration", content = ms.ToArray() }; inputFiles.Add(f); } } using (var fstream = File.Open(@"models\BFB_v6.3_Process_SS_total_opt_no_trim_mod.acmf", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "aspenfile", content = ms.ToArray() }; inputFiles.Add(f); } } }
public void Read() { Parallel.For(1, 100, i => { SimpleFile.Read(); }); }
public void Files_are_not_equal_if_content_is_different() { var file1 = new SimpleFile(Encoding.UTF8.GetBytes(TestString), "filename.txt"); var file2 = new SimpleFile(TestString + "extra", "filename.txt"); Assert.NotEqual(file1, file2); }
public void EnumerableQueryExpression() { var enumerable = from o in System.Linq.Enumerable.Range(1, 10) where SimpleFile.Write("") select SimpleFile.Write(o.ToString()); }
public bool AwaitShallNotBeOmittedInUsing() { using (new MemoryStream()) { return(SimpleFile.Write("")); } }
public void Files_are_equal_when_content_and_filenames_are_equal() { var file1 = new SimpleFile(Encoding.UTF8.GetBytes(TestString), "filename.txt"); var file2 = new SimpleFile(TestString, "filename.txt"); Assert.Equal(file1, file2); }
public void Test() { if (Success) { SimpleFile.Read(); } }
public void Test() { Assert.DoesNotThrow( () => { SimpleFile.Read(); SimpleFile.Read(); }); Assert.DoesNotThrow( delegate() { SimpleFile.Read(); SimpleFile.Read(); }); Runner.RunWithParameter( obj => { SimpleFile.Read(); SimpleFile.Read(); }); #pragma warning disable CS0168 // Variable is declared but never used #pragma warning disable CS8321 // Local function is declared but never used void LocalDoubleRead() #pragma warning restore CS8321 // Local function is declared but never used #pragma warning restore CS0168 // Variable is declared but never used { SimpleFile.Read(); SimpleFile.Read(); } }
/// <summary> /// copyFilesToDisk copies files from data contract to working directory. Assumes the sinter configuration file /// is named 'configuration' in the job description. Currently handles all the mapping from 'resource' names /// specified in the database schema to file names. /// </summary> /// <param name="job"></param> protected override void copyFilesToDisk(IJobConsumerContract job) { string cacheDir = Path.Combine(AppUtility.GetAppContext().BaseWorkingDirectory, job.SimulationId.ToString()); // NOTE: Aspen implementations only // Find 'aspenfile' // configuration file SimpleFile config = job.GetSimulationInputFiles().Single(f => f.name == "configuration"); string content = System.Text.Encoding.ASCII.GetString(config.content); var cacheFile = Path.Combine(cacheDir, configFileName); var filepath = Path.Combine(job.Process.WorkingDirectory, configFileName); File.WriteAllBytes(cacheFile, config.content); File.Copy(cacheFile, filepath); Dictionary <String, Object> jsonConfig = JsonConvert.DeserializeObject <Dictionary <String, Object> >(content); string modelfilename = (String)jsonConfig["model"]; SimpleFile model = job.GetSimulationInputFiles().Single(g => g.name == "model"); cacheFile = Path.Combine(cacheDir, modelfilename); filepath = Path.Combine(job.Process.WorkingDirectory, modelfilename); File.WriteAllBytes(cacheFile, model.content); File.Copy(cacheFile, filepath); }
public void Read() { var nested = NestedFactory.Create(); nested.DoSomething(); SimpleFile.Read(); }
private SimpleFile ToSimpleFile(DirectoryInfo dir, string alias = null) { if (!dir.Exists) { return(new SimpleFile { RawPath = dir.FullName, Filename = !string.IsNullOrEmpty(alias) ? alias : dir.Name, IsDir = true, }); } var root = new SimpleFile { RawPath = dir.FullName, Filename = !string.IsNullOrEmpty(alias) ? alias : dir.Name, IsDir = true, Files = new List <SimpleFile>() .Concat(dir.GetFiles().Select(ToSimpleFile)) .Concat(dir.GetDirectories().Select(i => ToSimpleFile(i))) .OrderBy(i => i.Filename) .ToList() }; return(root); }
public void Test() { var obj = new { test = SimpleFile.Write("") }; }
public void Read2(int start, int end) { Parallel.For(start, end, i => { SimpleFile.Read(); }); }
public void Read() { Parallel.ForEach(new [] { "" }, i => { SimpleFile.Read(); }); }
protected override void SetupTestParamters() { applicationName = "ACM"; simulationName = "VdVReactor"; jobId = 1; process = new InMemoryProcess(); using (var fstream = File.Open(@"models\VdV_Reactor_Dynamic_Config.json", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "configuration", content = ms.ToArray() }; inputFiles.Add(f); } } using (var fstream = File.Open(@"models\VdV_Reactor.acmf", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "aspenfile", content = ms.ToArray() }; inputFiles.Add(f); } } }
public void Read2() { if (DateTime.Today.Hour > 9) { SimpleFile.Read(); } }
public void InvalidOperationException() { throw new InvalidOperationException("Invalid"); #pragma warning disable 162 SimpleFile.Read(); #pragma warning restore 162 }
public void Test(string value, IDisposable item) { if (value == null) { throw new ArgumentNullException(nameof(value)); } SimpleFile.Read(); switch (item) { case BinaryReader br: value = "test"; break; case Stream _: value = "test2"; break; default: throw new InvalidOperationException(); } switch (value) { case "test": return; default: throw new InvalidOperationException(); } }
public void Read() { if (IsValid) { SimpleFile.Read(); } }
public void Read3() { Assert.DoesNotThrow(() => { SimpleFile.Read(); }); }
public void Test() { Assert.That(1, Is.EqualTo(1)); Assert.That(() => { SimpleFile.Read(); return(true); }, Is.EqualTo(true)); Assert.That(() => { SimpleFile.Read(); return(true); }); Assert.That(() => { SimpleFile.Read(); }, Throws.Nothing); Assert.That(() => { Console.WriteLine(""); }, Throws.Nothing); var result = false; Assert.That(() => result = SimpleFile.Write(""), Throws.Nothing); Assert.IsTrue(result); }
public Thread Test() { return(new Thread(() => { SimpleFile.Write(nameof(Test)); })); }
private void CopiesFile(SimpleFile file, ConnectionInfo inf) { string path = Directory.GetCurrentDirectory() + @"\Dir"; DirectoryInfo info = Directory.CreateDirectory(path); info.Attributes = info.Attributes & ~FileAttributes.ReadOnly; try { var fi = file.CopyToPath(path); if (Copied(path, fi.FullPath) && !Deleted()) { condition = true; } fi.Delete(); fi.Dispose(); file.Delete(); } finally { Directory.Delete(path, true); } }
protected override void SetupTestParamters() { applicationName = "ACM"; simulationName = "Hybrid"; jobId = 1; process = new InMemoryProcess(); using (var fstream = File.Open(@"models\Hybrid_v0.51_rev1.1_UQ_0809_sinter.json", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "configuration", content = ms.ToArray() }; inputFiles.Add(f); } } using (var fstream = File.Open(@"models\Hybrid_v0.51_rev1.1_UQ_0809.acmf", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "aspenfile", content = ms.ToArray() }; inputFiles.Add(f); } } }
public void Test() { lock (typeof(Lock)) { SimpleFile.Read(); } lock (typeof(Lock)) { Console.WriteLine("Test"); } lock (typeof(Lock)) SimpleFile.Read(); lock (_lock) { lock (typeof(Lock)) { SimpleFile.Read(); } lock (StaticLock) { SimpleFile.Read(); } } lock (_lock) SimpleFile.Read(); }
public FSEntry Find(string path) { // good: /foo/bar, /foo/bar/ // bad: foo, foo/bar, //foo/bar, /foo//bar, /foo/../foo/bar VirtualNode current = virtualFileSystem.RootNode; string[] elements = path.Split(PATH_SEPARATOR); foreach (string element in elements.Skip(1)) { VirtualNode child = current.GetChild(element); if (child != null) { current = child; } else { return(null); } } FSEntry result = null; if (current.IsDirectory) { result = new SimpleDirectory(current); } else { result = new SimpleFile(current); } return(result); }
protected override void SetupTestParamters() { applicationName = "AspenPlus"; simulationName = "MEA"; jobId = 2; process = new InMemoryProcess(); using (var fstream = File.Open(@"models\mea-abs-sinter.json", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "configuration", content = ms.ToArray() }; inputFiles.Add(f); } } using (var fstream = File.Open(@"models\mea-abs.bkp", FileMode.Open)) { byte[] bytes; using (var ms = new MemoryStream()) { fstream.CopyTo(ms); bytes = ms.ToArray(); var f = new SimpleFile() { name = "aspenfile", content = ms.ToArray() }; inputFiles.Add(f); } } }
public void TestAfterAnalyzation() { var readFile = GetMethodName(o => o.ReadFile); var callReadFile = GetMethodName(o => o.CallReadFile); var callCallReadFile = GetMethodName(o => o.CallCallReadFile); var read = GetMethodName(() => SimpleFile.Read()); var readAsync = GetMethodName(() => SimpleFile.ReadAsync()); var generator = new AsyncCodeGenerator(); Action <IProjectAnalyzationResult> afterAnalyzationFn = result => { Assert.AreEqual(1, result.Documents.Count); Assert.AreEqual(1, result.Documents[0].Namespaces.Count); Assert.AreEqual(1, result.Documents[0].Namespaces[0].Types.Count); Assert.AreEqual(3, result.Documents[0].Namespaces[0].Types[0].Methods.Count); var methods = result.Documents[0].Namespaces[0].Types[0].Methods.ToDictionary(o => o.Symbol.Name); Assert.IsTrue(methods[readFile].OmitAsync); // Check InvokedBy Assert.AreEqual(1, methods[readFile].InvokedBy.Count); Assert.AreEqual(methods[callReadFile], methods[readFile].InvokedBy[0]); Assert.AreEqual(1, methods[callReadFile].InvokedBy.Count); Assert.AreEqual(0, methods[callCallReadFile].InvokedBy.Count); // Check MethodReferences Assert.AreEqual(1, methods[readFile].MethodReferences.Count); var methodReference = methods[readFile].MethodReferences[0]; Assert.AreEqual(SyntaxKind.InvocationExpression, methodReference.ReferenceNode.Kind()); Assert.IsFalse(methodReference.Ignore); Assert.IsFalse(methodReference.AwaitInvocation); Assert.IsTrue(methodReference.UseAsReturnValue); Assert.IsNull(methodReference.ReferenceFunctionData); Assert.AreEqual(read, methodReference.ReferenceSymbol.Name); Assert.AreEqual(1, methodReference.ReferenceAsyncSymbols.Count); Assert.AreEqual(readAsync, methodReference.ReferenceAsyncSymbols[0].Name); // Check Conversion Assert.AreEqual(MethodConversion.ToAsync, methods[readFile].Conversion); Assert.AreEqual(MethodConversion.ToAsync, methods[callReadFile].Conversion); Assert.AreEqual(MethodConversion.ToAsync, methods[callCallReadFile].Conversion); }; var methodConversions = new[] { MethodConversion.ToAsync, MethodConversion.Smart }; foreach (var methodConversion in methodConversions) { var config = Configure(p => p .ConfigureAnalyzation(a => a .MethodConversion(symbol => { return(symbol.Name == readFile ? methodConversion : MethodConversion.Unknown); }) .Callbacks(c => c.AfterAnalyzation(afterAnalyzationFn)) ) ); Assert.DoesNotThrowAsync(async() => await generator.GenerateAsync(config)); } }
public void Test() { Assert.That(() => { SimpleFile.Clear(); return(SimpleFile.Write("")); }, Throws.Nothing); }
public void Test() { Runner.Run(s => { SimpleFile.Clear(); SimpleFile.Write(""); }); }