public TestResult RunTest(string name, IMachine machine, ITestResultBin bin, IDictionary <string, string> env) { ITestResource res = Repo.GetResource(name); TestResult tr = new TestResult(); try { string winDirectory = TestPathPrefix + name + "\\" + DateTime.Now.Ticks + "\\"; string targetFileName = winDirectory + name + ".bat"; using (Stream s = res.Read()) { machine.PutFile(targetFileName, s); } ProgramResult result = machine.RunProgram(targetFileName, "", winDirectory, env); // Hoover up artifacts *SLUURRRRRP* var artifacts = machine.ListFiles(winDirectory); foreach (var fileName in artifacts) { string tempFile = Path.GetTempFileName(); using (FileStream fs = File.Create(tempFile)) { machine.GetFile(fileName, fs); fs.Seek(0, SeekOrigin.Begin); bin.PutArtifact(new ArtifactInfo() { Name = fileName, Description = fileName, FileName = fileName }, fs); } File.Delete(tempFile); } tr.Success = result.ExitCode == 0; } catch (Exception e) { tr.Success = false; tr.StandardError = e.Message; } return(tr); }
private JObject CreateJsonPatch(ITestResource proxy) { var pomonaClient = Substitute.For <IPomonaClient>(); var jsonSerializer = (ITextSerializer) (new PomonaJsonSerializerFactory().GetSerializer( new ClientSerializationContextProvider(this.typeMapper, pomonaClient, pomonaClient))); using (var stringWriter = new StringWriter()) { jsonSerializer.Serialize(stringWriter, proxy, new SerializeOptions() { ExpectedBaseType = typeof(ITestResource) }); Console.WriteLine(stringWriter.ToString()); return(JObject.Parse(stringWriter.ToString())); // TODO: More assertions here! } }
private JObject CreateJsonPatch(ITestResource proxy) { var jsonSerializer = (ITextSerializer) (new PomonaJsonSerializerFactory(new ClientSerializationContextProvider(this.typeMapper, Substitute.For<IPomonaClient>())).GetSerializer()); using (var stringWriter = new StringWriter()) { jsonSerializer.Serialize(stringWriter, proxy, new SerializeOptions() { ExpectedBaseType = typeof(ITestResource) }); Console.WriteLine(stringWriter.ToString()); return JObject.Parse(stringWriter.ToString()); // TODO: More assertions here! } }