Ejemplo n.º 1
0
 public void ValidPathAtoms()
 {
     foreach (string validPathAtom in s_validPathAtoms)
     {
         XAssert.IsTrue(PathAtom.Validate((StringSegment)validPathAtom), "Case: {0}", validPathAtom);
     }
 }
Ejemplo n.º 2
0
        public void InvalidPathAtoms()
        {
            foreach (string invalidPathAtom in s_invalidPathAtoms)
            {
                XAssert.IsFalse(PathAtom.Validate((StringSegment)invalidPathAtom), "Case: {0}", invalidPathAtom);
            }

            if (!OperatingSystemHelper.IsUnixOS)
            {
                XAssert.IsFalse(PathAtom.Validate((StringSegment)"f*oo"), "Case: {0}", "f*oo");
                XAssert.IsFalse(PathAtom.Validate((StringSegment)"foo?"), "Case: {0}", "foo?");
                XAssert.IsFalse(PathAtom.Validate((StringSegment)"foo\\"), "Case: {0}", "foo\\");
                XAssert.IsFalse(PathAtom.Validate((StringSegment)"fo\\o"), "Case: {0}", "fo\\o");
            }
        }
Ejemplo n.º 3
0
        protected TemporaryStorageTestBase(ITestOutputHelper output)
            : base(output)
        {
            try
            {
                EngineEnvironmentSettings.SkipExtraneousPins.Value = true;
                string testClassName = LimitPathLength(GetType().Name);

                // In Xunit we can't really get the test method name. So we just pick an increasing integer.
                int testMethodNumber = 0;
                lock (s_temporaryNames)
                {
                    if (s_temporaryNames.TryGetValue(testClassName, out testMethodNumber))
                    {
                        testMethodNumber++;
                        s_temporaryNames[testClassName] = testMethodNumber;
                    }
                    else
                    {
                        s_temporaryNames.Add(testClassName, testMethodNumber);
                    }
                }

                // C# identifiers are valid path atoms. See IsValidPathAtom and  http://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx
                Contract.Assume(testClassName != null && PathAtom.Validate((StringSegment)testClassName));

                m_tempBase = Path.GetFullPath(Path.Combine(GetTempDir(), testClassName, testMethodNumber.ToString(CultureInfo.InvariantCulture)));

                if (Directory.Exists(m_tempBase))
                {
                    FileUtilities.DeleteDirectoryContents(m_tempBase);
                }

                Directory.CreateDirectory(m_tempBase);

                string moveDeleteDirectory = Path.Combine(m_tempBase, TestMoveDeleteCleaner.MoveDeleteDirectoryName);
                MoveDeleteCleaner = new TestMoveDeleteCleaner(moveDeleteDirectory);
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
Ejemplo n.º 4
0
 public void Validate()
 {
     XAssert.IsTrue(PathAtom.Validate((StringSegment)"AAA"));
     XAssert.IsFalse(PathAtom.Validate((StringSegment)("AAA" + Path.VolumeSeparatorChar)));
 }