public void LocateFeedbackReports() { var files = new List<string> { @"c:\a\def.b", }; var mockDirectory = new MockDirectory(files); var fileSystem = new Mock<IFileSystem>(); { fileSystem.Setup(f => f.Directory) .Returns(mockDirectory); } var collector = new FeedbackReportCollector(fileSystem.Object); var reports = collector.LocateFeedbackReports(); Assert.That( reports.Select(r => r.FullName), Is.EquivalentTo(files)); }
public void PreparePluginContainerForTransfer() { var files = new List<string> { typeof(string).Assembly.LocalFilePath(), typeof(HostApplicationCommands).Assembly.LocalFilePath(), Assembly.GetExecutingAssembly().LocalFilePath() }; var mockDirectory = new MockDirectory(files); var fileSystem = new Mock<IFileSystem>(); { fileSystem.Setup(f => f.Directory) .Returns(() => mockDirectory); } var uploads = new Mock<IStoreUploads>(); { uploads.Setup(u => u.Register(It.IsAny<string>())) .Callback<string>( f => { Assert.AreEqual(files[1], f); }) .Returns(new UploadToken()) .Verifiable(); } var configuration = new Mock<IConfiguration>(); { configuration.Setup(c => c.HasValueFor(It.IsAny<ConfigurationKey>())) .Returns(true); configuration.Setup(c => c.Value<List<string>>(It.IsAny<ConfigurationKey>())) .Returns(new List<string> { "bla" }); } var commands = new HostApplicationCommands(fileSystem.Object, uploads.Object, configuration.Object); var task = commands.PreparePluginContainerForTransfer(typeof(HostApplicationCommands).Assembly.GetName()); task.Wait(); uploads.Verify(u => u.Register(It.IsAny<string>()), Times.Once()); }
public void Read() { const string product = "product"; const string productVersion = "2.0"; const string testPurpose = "client"; const string operatingSystemName = "Os"; const string operatingSystemServicePack = "SP300"; const string operatingSystemCulture = "en-US"; const string operatingSystemPointerSize = "32"; const string applicationName = "application"; const string applicationVersion = "1.0"; const string environmentName = "environment_a"; const string notificationPath = @"c:\a\b\c\d"; // Note that the order of the elements is purposefully out of document order to // test the ordering of the test steps var files = new Dictionary<string, string>(); var console = BuildConsoleExecuteTestStepFunctions(3, environmentName, files); var msi = BuildMsiDeployTestStepFunctions(1, environmentName, files); var script = BuildScriptExecuteTestStepFunctions(2, environmentName, files); var xcopy = BuildXCopyDeployTestStepFunctions(0, environmentName, files); // Load the config file string var text = EmbeddedResourceExtracter.LoadEmbeddedTextFile( Assembly.GetExecutingAssembly(), "Sherlock.Console.Sherlock.Configuration.v12.xml"); string configText; { var builder = new StringBuilder(text); builder.Replace("${NAME_OF_PRODUCT_UNDER_TEST}$", product); builder.Replace("${VERSION_OF_PRODUCT_UNDER_TEST}$", productVersion); builder.Replace("${PURPOSE_OF_TEST}$", testPurpose); builder.Replace("${OPERATING_SYSTEM_NAME}$", operatingSystemName); builder.Replace("${OPERATING_SYSTEM_SERVICE_PACK}$", operatingSystemServicePack); builder.Replace("${OPERATING_SYSTEM_CULTURE}$", operatingSystemCulture); builder.Replace("${OPERATING_SYSTEM_POINTER_SIZE}$", operatingSystemPointerSize); builder.Replace("${APPLICATION_NAME}$", applicationName); builder.Replace("${APPLICATION_VERSION}$", applicationVersion); console.Item1(builder); msi.Item1(builder); script.Item1(builder); xcopy.Item1(builder); builder.Replace("${NOTIFICATION_DIRECTORY_FULL_PATH_GOES_HERE}$", notificationPath); configText = builder.ToString(); } var doc = XDocument.Parse(configText, LoadOptions.None); var file = new MockFile(files); var directory = new MockDirectory(xcopy.Item4); var fileSystem = new Mock<IFileSystem>(); { fileSystem.Setup(f => f.File) .Returns(file); fileSystem.Setup(f => f.Directory) .Returns(directory); } StoreFileDataForEnvironment storage = (environment, step, name, data) => { switch (step) { case 0: xcopy.Item2(environment, step, name, data); break; case 1: msi.Item2(environment, step, name, data); break; case 2: script.Item2(environment, step, name, data); break; case 3: console.Item2(environment, step, name, data); break; default: Assert.Fail(); break; } }; var reader = new ConfigurationReaderVersion12(fileSystem.Object, storage); var config = reader.Read(doc); Assert.IsNotNull(config); Assert.AreEqual(product, config.Test.ProductUnderTest); Assert.AreEqual(productVersion, config.Test.VersionOfProductUnderTest); Assert.AreEqual(testPurpose, config.Test.Description); Assert.AreEqual(1, config.Test.Environments.Count()); var testSteps = config.Test.TestSteps.ToList(); console.Item3(testSteps[0] as ConsoleExecuteTestStepDescription); msi.Item3(testSteps[1] as MsiInstallTestStepDescription); script.Item3(testSteps[2] as ScriptExecuteTestStepDescription); xcopy.Item3(testSteps[3] as XCopyTestStepDescription); Assert.AreEqual(notificationPath, config.Test.ReportPath); }