public void DeleteFileShouldRemoveFileFromDisk() { var wrapper = new FileSystemWrapper(); var date = DateTime.Now; string destinationPath = string.Format("{0}\\TestResults\\{1}\\{2}", StrixPlatform.Environment.WorkingDirectory, date.Year, date.Month); string fullPath = destinationPath + "\\Strix_losuiltje.png"; string originalFullPath = StrixPlatform.Environment.WorkingDirectory + "\\TestFiles\\Strix_losuiltje.png"; if (!System.IO.Directory.Exists(destinationPath)) { System.IO.Directory.CreateDirectory(destinationPath); } if (!System.IO.File.Exists(fullPath)) { System.IO.File.Copy(originalFullPath, fullPath); } string root = Path.Combine(StrixPlatform.Environment.WorkingDirectory, "TestResults"); string fileName = "Strix_losuiltje"; string fileExtension = "png"; wrapper.DeleteFile(string.Format("{0}\\{1}.{2}", System.IO.Path.Combine(root, date.Year.ToString(), date.Month.ToString()), fileName, fileExtension)); wrapper.ProcessDeleteQueue(); bool result = System.IO.File.Exists(fullPath); Assert.IsFalse(result); }
public void GetHtmlTemplateDataForUnknownCultureShouldGetTemplateForDefaultCulture() { var wrapper = new FileSystemWrapper(); var result = wrapper.GetHtmlTemplate(Path.Combine(StrixPlatform.Environment.WorkingDirectory, "TestFiles"), "AccountInformationMail", "fr"); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("Your account for [[SITENAME]]", result[0].Subject); Assert.AreEqual("en", result[0].Culture); }
private static IWebAssetItemMerger CreateAssetMerger(ControllerContext context) { IPathResolver pathResolver = new PathResolver(); IFileSystem fileSystem = new FileSystemWrapper(); IUrlResolver urlResolver = new UrlResolver(new UrlHelper(context.RequestContext)); IWebAssetLocator assetLocator = new WebAssetLocator(context.HttpContext.IsDebuggingEnabled, pathResolver, fileSystem); ICacheManager cacheManager = new CacheManagerWrapper(); IWebAssetRegistry assetRegistry = new WebAssetRegistry(cacheManager, assetLocator, pathResolver, fileSystem); IWebAssetItemMerger assetItemMerger = new WebAssetItemMerger(assetRegistry, urlResolver, context.HttpContext.Server); return assetItemMerger; }
public void EncodeTest() { //Arrange var cloudStorageConfiguration = new CloudStorageConfiguration(CloudStorageAccount.DevelopmentStorageAccount, new Version()); var queueVideoRepository = new QueueVideoRepository(cloudStorageConfiguration.StorageAccount.CreateCloudQueueClient()); var videoRepository = new FakeVideoRepository(_blobSource, _blobDestination); var screenshotRepository = new FakeScreenshotRepository(_blobDestination); var mediaInfoReader = new MediaInfoReader(); var encoder = new Encoder(); var fileSystemWrapper = new FileSystemWrapper(); var queueProcess = new QueueProcess(1000, queueVideoRepository); var downloadProcess = new DownloadProcess(5, videoRepository, fileSystemWrapper); var encoderProcess = new EncodeProcess(5, encoder, videoRepository, mediaInfoReader, queueVideoRepository, fileSystemWrapper); var uploadProcess = new UploadProcess(5, videoRepository, screenshotRepository, fileSystemWrapper); var finishProcess = new FinishProcess(queueVideoRepository, videoRepository, fileSystemWrapper); var queueContainer = new ProcessContainer<object, QueueInformation, DownloadInformation>(queueProcess, downloadProcess); var downloadContainer = new ProcessContainer<QueueInformation, DownloadInformation, EncodeInformation>(downloadProcess, encoderProcess); var encoderContainer = new ProcessContainer<DownloadInformation, EncodeInformation, UploadInformation>(encoderProcess, uploadProcess); var uploadContainer = new ProcessContainer<EncodeInformation, UploadInformation, object>(uploadProcess, finishProcess); var processManager = new EncodeProcessManager(queueVideoRepository.DeleteMessageLocal); processManager.Add(queueContainer); processManager.Add(downloadContainer); processManager.Add(encoderContainer); processManager.Add(uploadContainer); var timer = new Timer(UpdateMessages, queueVideoRepository, (int) queueVideoRepository.InvisibleTime.TotalMilliseconds/2, (int) queueVideoRepository.InvisibleTime.TotalMilliseconds/2); //Act & Assert Task task = processManager.Start(); StartQueueWork(); Thread.Sleep(30000); while (queueVideoRepository.ApproximateMessageCount > 0) { Thread.Sleep(60000); } //Thread.Sleep(50*60*1000); processManager.Stop(); task.Wait(); }
public void GetHtmlTemplateDataForSpecificCultureShouldGetTemplateForCulture() { var wrapper = new FileSystemWrapper(); var result = wrapper.GetHtmlTemplate(Path.Combine(StrixPlatform.Environment.WorkingDirectory, "TestFiles"), "AccountInformationMail", "en"); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("Your account for [[SITENAME]]", result[0].Subject); Assert.AreEqual(@"<h1>Your account for [[SITENAME]]</h1> <p>Dear [[USERNAME]]</p> <p> A new user account for [[SITENAME]] has been created for you. When you are ready to select a password, please click the link below. You'll then receive a new link that will allow you to enter a password. </p> <a href=""[[BASEURL]]/Account/SendPasswordLink/[[USERID]]"">Select a password</a>", result[0].Body); Assert.AreEqual("en", result[0].Culture); }
private void button1_Click(object sender, EventArgs e) { var logger = Substitute.For<ILogger>(); var facade = Substitute.For<IBuildServiceFacade>(); var filesys = new FileSystemWrapper(); ProcessSettings processSettings = new ProcessSettings(); processSettings.BaseResultPath = @"c:\mocs\"; processSettings.NunitAssemblyPath = @"C:\Program Files\NUnit 2.5.9\bin\net-2.0\framework"; processSettings.CscPath = @"C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe"; processSettings.NunitConsolePath = @"C:\Program Files\NUnit 2.5.9\bin\net-2.0\nunit-console.exe"; processSettings.SourcesPath = ""; processSettings.OutputPath = ""; processSettings.TestLogFileName = "testresult.xml"; processSettings.NunitTimeOut = 5000; processSettings.CleanUp = true; processSettings.Assignment = CreateTestAssignment(facade); processSettings.Submit = CreateTestSubmit(); processSettings.Submit.TournamentAssignment.Assignment = processSettings.Assignment; ServiceLocator services = ServiceLocator.Instance; services.AddService(typeof(IFileSystem), filesys); BaseProcess process = new MoCSValidationProcess(processSettings, filesys); ExecuteProcessResult result = process.Process(); richTextBox1.Clear(); if (result.Result == ExitCode.Success) { this.panel1.BackColor = Color.Green; } else { this.panel1.BackColor = Color.Red; richTextBox1.AppendText(result.Output); } }
public void GetHtmlTemplateDataShouldGetTemplatesForAllCultures() { var wrapper = new FileSystemWrapper(); var result = wrapper.GetHtmlTemplate(Path.Combine(StrixPlatform.Environment.WorkingDirectory, "TestFiles"), "AccountInformationMail", null); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("Your account for [[SITENAME]]", result[0].Subject); Assert.AreEqual(@"<h1>Your account for [[SITENAME]]</h1> <p>Dear [[USERNAME]]</p> <p> A new user account for [[SITENAME]] has been created for you. When you are ready to select a password, please click the link below. You'll then receive a new link that will allow you to enter a password. </p> <a href=""[[BASEURL]]/Account/SendPasswordLink/[[USERID]]"">Select a password</a>", result[0].Body); Assert.AreEqual("en", result[0].Culture); Assert.AreEqual("Uw account op [[SITENAME]]", result[1].Subject); Assert.AreEqual(@"<h1>Uw account op [[SITENAME]]</h1> <p>Beste [[USERNAME]]</p> <p> Er is een nieuw account op [[SITENAME]] voor u aangemaakt. Wanneer u uw wachtwoord wilt kiezen, gebruik dan de link hieronder. U krijgt dan een nieuwe link toegestuurd waarmee u uw wachtwoord kunt instellen. </p> <a href=""[[BASEURL]]/Account/SendPasswordLink/[[USERID]]"">Kies uw wachtwoord</a>", result[1].Body); Assert.AreEqual("nl", result[1].Culture); }
public void SaveImageFromByteArrayShouldSaveImageToDisk() { var wrapper = new FileSystemWrapper(); var date = DateTime.Now; string fileName = "Strix_losuiltje_from_bytearray"; string fileExtension = "png"; string destinationPath = string.Format("{0}\\TestResults\\{1}\\{2}", StrixPlatform.Environment.WorkingDirectory, date.Year, date.Month); string originalFullPath = StrixPlatform.Environment.WorkingDirectory + "\\TestFiles\\Strix_losuiltje_2.png"; Stream inputStream = new FileStream(originalFullPath, FileMode.Open); byte[] bytes = new byte[inputStream.Length]; inputStream.Read(bytes, 0, (int)inputStream.Length); bool expected = true; bool actual; actual = wrapper.SaveFile(string.Format("{0}\\{1}.{2}", destinationPath, fileName, fileExtension), bytes); Assert.AreEqual(expected, actual); }
public FileSystemWrapperTests() { _fileSystemWrapper = new FileSystemWrapper(); }