public void Deploy_WithSourceAndDestinationDirectories_CopiesOneToTheOther() { // arrange var webroot = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); webroot.Create(); var destination = new SubtextDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); destination.Create(); var dir = webroot.Combine(Guid.NewGuid().ToString()); dir.Create(); var file = webroot.CombineFile(Guid.NewGuid().ToString()); using (var sw = new StreamWriter(file.OpenWrite())) sw.WriteLine(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit."); var fileDeployer = new FileDeployer(webroot, destination); // act fileDeployer.Deploy(); // assert Assert.IsTrue(destination.CombineFile(file.Name).Exists); Assert.IsTrue(destination.Combine(dir.Name).Exists); }
public void Init_Normal_Good() { const int magicNum = 15; var data = FileDeployer.data1; var fname = FileDeployer.GetFilename(); FileDeployer.DeployFile(fname, data); using (var reader = _GetReader(fname)) { reader.LinesToReadAtOnce = magicNum; Assert.AreEqual( magicNum, reader.LinesToReadAtOnce ); Assert.AreEqual( false, reader.ReachedEndOfFile ); } FileDeployer.UnDeployFile(fname); }
private Profiler(WindowsPhoneDevice device) { _device = device; GetInternalDevice(); GetConmanServer(); _fileDeployer = _internalDevice.GetFileDeployer(); }
public static void CopyFiles(FileDeployer deployer, string desktoPath, string devicePath, string deployFileFilter) { string[] filters = deployFileFilter.Split(','); foreach (string file in Directory.GetFiles(Path.GetDirectoryName(desktoPath), Path.GetFileName(desktoPath))) { if (AcceptFile(file, filters)) { Console.WriteLine("Deploying file: {0} to {1}", file, devicePath); deployer.SendFile(file, devicePath + Path.GetFileName(file)); } } }
private static void DeployDotNetFramework(Device device, string version) { FileDeployer fd = device.GetFileDeployer(); FrameWorkInfo info = _deployment[version]; fd.DownloadPackage(info.PackageId); RemoteProcess installer = device.GetRemoteProcess(); installer.Start("wceload.exe", String.Format(@"/noui \windows\{0}", info.PackageFullPath)); WaitToFinishOrTimeout(installer, new TimeSpan(0, 0, 30, 0)); }
public void RemoveOldFiles_WithDestination_RemovesUnusedFiles() { // arrange var webroot = new Mock <IDirectory>(); var destination = new Mock <IDirectory>(); destination.Setup(d => d.CombineFile(It.IsAny <string>())).Returns(new Mock <IFile>().Object); var fileDeployer = new FileDeployer(webroot.Object, destination.Object); // act fileDeployer.RemoveOldFiles(); // assert destination.Verify(d => d.CombineFile("AggDefault.aspx")); }
public void GetData_Normal_Good() { var expected = FileDeployer.data1; var fname = FileDeployer.GetFilename(); FileDeployer.DeployFile(fname, expected); var reader = _GetReader(fname); var result = reader.GetData(expected.Length); Assert.AreEqual( expected, result ); FileDeployer.UnDeployFile(fname); }
public void GetData_AskForMoreLinesThanExists_Good() { var expected = FileDeployer.data1; var fname = FileDeployer.GetFilename(); FileDeployer.DeployFile(fname, expected); var reader = _GetReader(fname); var result = reader.GetData(expected.Length + 1); Assert.AreEqual( expected, result ); FileDeployer.UnDeployFile(fname); }
public void GetData_NegativeCount_ReturnEmpty() { var expected = new string[0]; var data = FileDeployer.data1; var fname = FileDeployer.GetFilename(); FileDeployer.DeployFile(fname, data); var reader = _GetReader(fname); var result = reader.GetData(-1); Assert.AreEqual( expected, result ); FileDeployer.UnDeployFile(fname); }
public void GetData_TwoTimes_Good() { var expected = FileDeployer.data1; var fname = FileDeployer.GetFilename(); FileDeployer.DeployFile(fname, expected); var reader = _GetReader(fname); reader.GetData(expected.Length - 1); var result = reader.GetData(1); Assert.AreEqual( expected[expected.Length - 1], result[0] ); FileDeployer.UnDeployFile(fname); }
public void RemoveOldDirectories_WithDestination_RemovesUnusedDirectories() { // arrange var webroot = new Mock <IDirectory>(); var destination = new Mock <IDirectory>(); destination.Setup(d => d.Combine(It.IsAny <string>())).Returns(new Mock <IDirectory>().Object); destination.Setup(d => d.CombineFile(It.IsAny <string>())).Returns(new Mock <IFile>().Object); var fileDeployer = new FileDeployer(webroot.Object, destination.Object); // act fileDeployer.RemoveOldDirectories(); // assert destination.Verify(d => d.Combine("Admin")); destination.Verify(d => d.Combine("HostAdmin")); destination.Verify(d => d.Combine("Install")); destination.Verify(d => d.Combine("SystemMessages")); }
public static void PublishTestLog(FileDeployer deployer, string path) { string logFile = Path.Combine(path, "db4ounit.log"); deployer.ReceiveFile(@"\db4ounit.log", logFile); try { using (StreamReader reader = File.OpenText(logFile)) { string line; while ((line = reader.ReadLine()) != null) { Console.Error.WriteLine(line); } } } catch (FileNotFoundException) { Console.Error.WriteLine("Db4ounit.log has not been generated."); } }
static int Main(string[] args) { try { if (args.Length != 4) { Usage(); return(1); } string platformId = args[0]; string deviceId = args[1]; string packageID; switch (args[2]) { case "2.0": packageID = NetCf20PackageId; break; case "3.5": packageID = NetCf35PackageId; break; default: packageID = args[2]; break; } string cabName = args[3]; // Get the datastore object var dsmgr = new DatastoreManager(1033); var platform = dsmgr.GetPlatform(new ObjectId(platformId)); var device = platform.GetDevice(new ObjectId(deviceId)); Console.WriteLine("Connecting to device..."); device.Connect(); FileDeployer fileDeployer = device.GetFileDeployer(); Console.WriteLine("Deploying package..."); fileDeployer.DownloadPackage(new ObjectId(packageID)); Console.WriteLine("Installing package..."); RemoteProcess installer = device.GetRemoteProcess(); installer.Start("wceload.exe", cabName); while (installer.HasExited() != true) { System.Threading.Thread.Sleep(1000); } var exitCode = installer.GetExitCode(); if (exitCode != 0) { Console.WriteLine("Installation failed. Exit code: {0}", exitCode); } else { Console.WriteLine("Installation succeeded."); } return(exitCode); } catch (Exception ex) { Console.WriteLine("ERROR: {0}", ex); return(1); } }