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 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 CleanupShouldNotDeleteDirectoriesIfRunSettingsSpecifiesSo() { string runSettingxml = @"<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>"; StringReader stringReader = new StringReader(runSettingxml); XmlReader reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); MSTestSettingsProvider mstestSettingsProvider = new MSTestSettingsProvider(); mstestSettingsProvider.Load(reader); 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)); testDeployment.Cleanup(); this.mockFileUtility.Verify(fu => fu.DeleteDirectories(It.IsAny <string>()), Times.Never); }
private Mock <IRunSettings> GetMockedIRunSettings(string runSettingxml) { var mockRunSettings = new Mock <IRunSettings>(); mockRunSettings.Setup(rs => rs.SettingsXml).Returns(runSettingxml); StringReader stringReader = new StringReader(runSettingxml); XmlReader reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); MSTestSettingsProvider mstestSettingsProvider = new MSTestSettingsProvider(); reader.ReadToFollowing("MSTestV2"); mstestSettingsProvider.Load(reader); return(mockRunSettings); }