public void DeployShouldReturnTrueWhenDeploymentEnabledSetToTrueAndHasDeploymentItems() { var testCase = new TestCase("A.C.M", new System.Uri("executor://testExecutor"), Assembly.GetExecutingAssembly().Location); var kvpArray = new[] { new KeyValuePair <string, string>( DefaultDeploymentItemPath, DefaultDeploymentItemOutputDirectory) }; testCase.SetPropertyValue(DeploymentItemUtilityTests.DeploymentItemsProperty, kvpArray); var testDeployment = new TestDeployment( new DeploymentItemUtility(this.mockReflectionUtility.Object), new DeploymentUtility(), this.mockFileUtility.Object); string runSettingxml = @"<DeploymentEnabled>True</DeploymentEnabled>"; StringReader stringReader = new StringReader(runSettingxml); XmlReader reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); MSTestSettingsProvider mstestSettingsProvider = new MSTestSettingsProvider(); mstestSettingsProvider.Load(reader); // Deployment should happen Assert.IsTrue(testDeployment.Deploy(new List <TestCase> { testCase }, null, new Mock <IFrameworkHandle>().Object)); // Deployment directories should get created Assert.IsNotNull(testDeployment.GetDeploymentDirectory()); }
public void DeployShouldReturnFalseWhenDeploymentEnabledSetToTrueButHasNoDeploymentItems() { var testCase = new TestCase("A.C.M", new System.Uri("executor://testExecutor"), "A"); testCase.SetPropertyValue(DeploymentItemUtilityTests.DeploymentItemsProperty, null); var testDeployment = new TestDeployment( new DeploymentItemUtility(this.mockReflectionUtility.Object), new DeploymentUtility(), this.mockFileUtility.Object); string runSettingxml = @"<DeploymentEnabled>True</DeploymentEnabled>"; StringReader stringReader = new StringReader(runSettingxml); XmlReader reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); MSTestSettingsProvider mstestSettingsProvider = new MSTestSettingsProvider(); mstestSettingsProvider.Load(reader); // Deployment should not happen Assert.IsFalse(testDeployment.Deploy(new List <TestCase> { testCase }, null, null)); // Deployment directories should get created Assert.IsNotNull(testDeployment.GetDeploymentDirectory()); }
public void CleanupShouldNotDeleteDirectoriesIfRunDirectoiresIsNull() { var testDeployment = new TestDeployment(null, null, this.mockFileUtility.Object); testDeployment.Cleanup(); this.mockFileUtility.Verify(fu => fu.DeleteDirectories(It.IsAny <string>()), Times.Never); }
public void GetDeploymentInformationShouldReturnAppBaseDirectoryIfRunDirectoryIsNull() { TestDeployment.Reset(); var properties = TestDeployment.GetDeploymentInformation(Assembly.GetExecutingAssembly().Location); var applicationBaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var expectedProperties = new Dictionary <string, object> { { TestContextPropertyStrings.TestRunDirectory, applicationBaseDirectory }, { TestContextPropertyStrings.DeploymentDirectory, applicationBaseDirectory }, { TestContextPropertyStrings.ResultsDirectory, applicationBaseDirectory }, { TestContextPropertyStrings .TestRunResultsDirectory, applicationBaseDirectory }, { TestContextPropertyStrings .TestResultsDirectory, applicationBaseDirectory }, { TestContextPropertyStrings.TestDir, applicationBaseDirectory }, { TestContextPropertyStrings.TestDeploymentDir, applicationBaseDirectory }, { TestContextPropertyStrings.TestLogsDir, applicationBaseDirectory } }; Assert.IsNotNull(properties); CollectionAssert.AreEqual(expectedProperties.ToList(), properties.ToList()); }
public void GetDeploymentItemsReturnsDeploymentItems() { // Arrange. var testDeployment = new TestDeployment(new DeploymentItemUtility(this.mockReflectionUtility.Object), null, null); // setup mocks var methodLevelDeploymentItems = new[] { new KeyValuePair <string, string>( DefaultDeploymentItemPath, DefaultDeploymentItemOutputDirectory) }; var classLevelDeploymentItems = new[] { new KeyValuePair <string, string>( DefaultDeploymentItemPath + "\\temp2", DefaultDeploymentItemOutputDirectory) }; var memberInfo = typeof(DesktopTestDeploymentTests).GetMethod( "GetDeploymentItemsReturnsDeploymentItems"); this.SetupDeploymentItems(memberInfo, methodLevelDeploymentItems); this.SetupDeploymentItems(typeof(DesktopTestDeploymentTests), classLevelDeploymentItems); // Act. var deploymentItems = testDeployment.GetDeploymentItems(memberInfo, typeof(DesktopTestDeploymentTests), this.warnings); // Assert. var expectedDeploymentItems = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>( DefaultDeploymentItemPath, DefaultDeploymentItemOutputDirectory), new KeyValuePair <string, string>( DefaultDeploymentItemPath + "\\temp2", DefaultDeploymentItemOutputDirectory) }; CollectionAssert.AreEqual(expectedDeploymentItems, deploymentItems.ToArray()); }
public void GetDeploymentInformationShouldReturnRunDirectoryInformationIfSourceIsNotNull() { // Arrange. TestRunDirectories testRunDirectories; var testCase = this.GetTestCase(Assembly.GetExecutingAssembly().Location); // Setup mocks. var testDeployment = this.CreateAndSetupDeploymentRelatedUtilities(out testRunDirectories); var mockRunContext = new Mock <IRunContext>(); mockRunContext.Setup(rc => rc.TestRunDirectory).Returns(testRunDirectories.RootDeploymentDirectory); Assert.IsTrue(testDeployment.Deploy(new List <TestCase> { testCase }, mockRunContext.Object, new Mock <IFrameworkHandle>().Object)); // Act. var properties = TestDeployment.GetDeploymentInformation(Assembly.GetExecutingAssembly().Location); // Assert. var expectedProperties = new Dictionary <string, object> { { TestContextPropertyStrings.TestRunDirectory, testRunDirectories.RootDeploymentDirectory }, { TestContextPropertyStrings.DeploymentDirectory, testRunDirectories.OutDirectory }, { TestContextPropertyStrings.ResultsDirectory, testRunDirectories.InDirectory }, { TestContextPropertyStrings .TestRunResultsDirectory, testRunDirectories.InMachineNameDirectory }, { TestContextPropertyStrings .TestResultsDirectory, testRunDirectories.InDirectory }, { TestContextPropertyStrings.TestDir, testRunDirectories.RootDeploymentDirectory }, { TestContextPropertyStrings.TestDeploymentDir, testRunDirectories.OutDirectory }, { TestContextPropertyStrings.TestLogsDir, testRunDirectories.InMachineNameDirectory } }; Assert.IsNotNull(properties); CollectionAssert.AreEqual(expectedProperties.ToList(), properties.ToList()); }
public static async Task <TestService> DeployContractAndGetServiceAsync(Web3 web3, TestDeployment testDeployment, CancellationTokenSource cancellationTokenSource = null) { var receipt = await DeployContractAndWaitForReceiptAsync(web3, testDeployment, cancellationTokenSource); return(new TestService(web3, receipt.ContractAddress)); }
public static Task <string> DeployContractAsync(Web3 web3, TestDeployment testDeployment) { return(web3.Eth.GetContractDeploymentHandler <TestDeployment>().SendRequestAsync(testDeployment)); }
public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Web3 web3, TestDeployment testDeployment, CancellationTokenSource cancellationTokenSource = null) { return(web3.Eth.GetContractDeploymentHandler <TestDeployment>().SendRequestAndWaitForReceiptAsync(testDeployment, cancellationTokenSource)); }