/// <summary> /// Create an empty file with a random file name in the TestPath, /// which points to our test Perforce workspace. /// </summary> /// <returns></returns> internal string GetTempFileName(PersistedP4OptionSettings settings) { if (!Directory.Exists(settings.WorkspacePath)) { Directory.CreateDirectory(settings.WorkspacePath); } string fileName = Path.GetRandomFileName(); string filePath = Path.Combine(settings.WorkspacePath, fileName); var stream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite); stream.Close(); // register the filePath with the map so we can Send the command to Perforce string warning; if (_map == null) { _map = new Map(false); } _map.GetP4FileName(filePath, out warning); Assert.IsTrue(String.IsNullOrEmpty(warning), warning); return(filePath); }
public static void MyClassInitialize(TestContext testContext) { // For these provider tests, we're going to use a settings group specifically named // SccProviderServiceTest. Note: If tests are ever added that specifically need a // streams depot, those tests will have to use a different settings group. P4OptionsDefaultsProvider defaults = new P4OptionsDefaultsProvider(new List <string> { "P4ServiceTest", "UnitTestDefaults" }); settings = new PersistedP4OptionSettings(defaults); }