Ejemplo n.º 1
0
 public void ToStringTest()
 {
     DependsOn.Windows(() => {
         string formatted1 = PathStringPool.Get(Path).ToString(PathStringFormatterTests.Format);
         Assert.AreEqual(Resources.PathStringToStringResult, formatted1);
         string formatted2 = PathStringPool.Get(Path).ToString("");
         Assert.AreEqual(Path, formatted2);
     });
 }
Ejemplo n.º 2
0
        public void FormatTest()
        {
            DependsOn.Windows(() => {
                var path      = PathStringPool.Get(PathStringTests.Path);
                var formatter = new PathStringFormatter();

                string formatted = formatter.Format(Format, path, null);
                Assert.AreEqual(Resources.PathStringToStringResult, formatted);
            });
        }
Ejemplo n.º 3
0
            public void PathStringPoolTest()
            {
                PathString path;

                path = PathStringPool.Get();
                path = PathStringPool.Get("0");
                path = PathStringPool.Get("0", "1");
                path = PathStringPool.Get("0", "1", "2");
                path = PathStringPool.Get("0", "1", "2", "3");
                path = PathStringPool.Get("0", "1", "2", "3", "4");
                path = PathStringPool.Get("0", "1", "2", "3", "4", "5");
                path = PathStringPool.Get(new string[] { "x" });
                PathStringPool.Clear();
            }
Ejemplo n.º 4
0
        public void SaveTest()
        {
            var dir = PathStringPool.Get("Temp/Logs");

            Directory.CreateDirectory(dir);
            SaveER(dir, new Exception());
            SaveER(dir, new NullReferenceException());
            SaveER(dir, new DivideByZeroException());
            SaveER(dir, new InvalidOperationException());
            SaveER(dir, new InvalidDataException());
            SaveER(dir, new InvalidPathFormatException("xyz"));
            SaveER(dir, new AccessViolationException());
            SaveER(dir, new StackOverflowException());
            SaveER(dir, new ObjectDisposedException("a"));
            SaveER(dir, new ArgumentNullException("b"));
            SaveER(dir, new OperationCanceledException());
            SaveER(dir, new AggregateException(new Exception(), new Exception(), new Exception("c", new Exception("d", new Exception()))));
        }
Ejemplo n.º 5
0
        public void SaveTest2()
        {
            var dir = PathStringPool.Get("Temp/Logs");

            Directory.CreateDirectory(dir);
            using var cts  = new CancellationTokenSource();
            using var cts2 = new CancellationTokenSource();
            cts2.Cancel();
            var ex = new AggregateException(
                new Exception(),
                new NullReferenceException(),
                new DivideByZeroException(),
                new InvalidOperationException(),
                new InvalidDataException(),
                new InvalidPathFormatException("xyz"),
                new AccessViolationException(),
                new StackOverflowException(),
                new ObjectDisposedException("a"),
                new ArgumentNullException("b"),
                new OperationCanceledException(),
                new AggregateException(
                    new Exception(),
                    new Exception(),
                    new Exception("c", new Exception("d", new Exception("e",
                                                                        new OperationCanceledException(cts.Token)
                                                                        ))),
                    new SecurityException(),
                    new SecurityException(
                        "message",
                        this.GetType(),
                        "state"
                        ),
                    new SecurityException(
                        "message",
                        new Exception()
                        )
                    ),
                new OperationCanceledException(cts2.Token),
                new OperationCanceledException(CancellationToken.None)
                );

            ErrorReportBuilder.Create(ex).Save(dir, "FULL");
        }
Ejemplo n.º 6
0
 /// <summary>
 ///  ログファイルのパス文字列を生成します。
 /// </summary>
 /// <param name="dt">作成日時です。</param>
 /// <param name="proc">プロセスを表すオブジェクトです。</param>
 /// <param name="tag">ファイル名に付加するタグです。既定値は<see langword="null"/>です。</param>
 /// <param name="useLongName">
 ///  長い形式を利用する場合は<see langword="true"/>、
 ///  短い形式を利用する場合は<see langword="false"/>を指定します。
 ///  既定値は<see langword="false"/>です。
 /// </param>
 /// <returns>生成されたログファイルのパス文字列です。</returns>
 public static PathString CreatePath(DateTime dt, Process proc, string?tag = null, bool useLongName = true)
 {
     return(PathStringPool.Get(Create(dt, proc, tag, useLongName)));
 }
Ejemplo n.º 7
0
 /// <summary>
 ///  ログファイルのパス文字列を生成します。
 /// </summary>
 /// <param name="tag">ファイル名に付加するタグです。</param>
 /// <returns>生成されたログファイルのパス文字列です。</returns>
 public static PathString CreatePath(string?tag)
 {
     return(PathStringPool.Get(Create(tag)));
 }
Ejemplo n.º 8
0
 /// <summary>
 ///  ログファイルのパス文字列を生成します。
 /// </summary>
 /// <returns>生成されたログファイルのパス文字列です。</returns>
 public static PathString CreatePath()
 {
     return(PathStringPool.Get(Create()));
 }
Ejemplo n.º 9
0
            public void PathStringTest()
            {
                PathString?pathStr;
                bool       boolVal;
                string?    str;

                PathString[]? arrayOfPathStr;
                FileSystemEntryEnumerator?entries;
                DriveInfo?     driveInfo;
                DirectoryInfo? dinfo;
                FileInfo?      finfo;
                FileSystemInfo?fsinfo;
                Uri            uri;
                int            num;
                PathString     path  = PathStringPool.Get();
                var            sinfo = new SerializationInfo(typeof(PathString), new FormatterConverter());

                pathStr        = path.BasePath;
                boolVal        = path.IsRoot;
                boolVal        = path.IsDrive;
                boolVal        = path.IsDirectory;
                boolVal        = path.IsFile;
                boolVal        = path.Exists;
                pathStr        = path.Combine();
                pathStr        = path.Combine("aa");
                pathStr        = path.Combine("aa", "bb");
                pathStr        = path.Combine("aa", "bb", "cc");
                pathStr        = path.Combine("aa", "bb", "cc", "dd");
                pathStr        = path.Combine("aa", "bb", "cc", "dd", "ee");
                pathStr        = path.Combine(Array.Empty <string>());
                pathStr        = path.GetDirectoryName();
                str            = path.GetFileName();
                str            = path.GetFileNameWithoutExtension();
                str            = path.GetExtension();
                pathStr        = path.ChangeFileName("xyz");
                pathStr        = path.ChangeExtension("0");
                pathStr        = path.EnsureNotFound();
                pathStr        = path.GetRootPath();
                str            = path.GetRelativePath();
                str            = path.GetRelativePath(path);
                arrayOfPathStr = path.GetEntryArray();
                entries        = path.GetEntries();
                entries        = path.GetEntries("*");
                entries        = path.GetEntries("*", SearchOption.TopDirectoryOnly);
                //entries      = path.GetEntries("*", new EnumerationOptions());
                driveInfo = path.GetDriveInfo();
                dinfo     = path.GetDirectoryInfo();
                finfo     = path.GetFileInfo();
                fsinfo    = path.GetFileSystemInfo();
                str       = path.GetOriginalString();
                uri       = path.AsUri();
                str       = path.ToString();
                str       = path.ToString(string.Empty);
                str       = path.ToString(new EmptyFormatProvider());
                str       = path.ToString(string.Empty, new EmptyFormatProvider());
                boolVal   = path.Equals(new object());
                boolVal   = path.Equals(path);
                boolVal   = path.Equals(string.Empty);
                num       = path.CompareTo(new object());
                num       = path.CompareTo(path);
                num       = path.CompareTo(string.Empty);
                num       = path.GetHashCode();
                pathStr   = path + "123";
                str       = path - path;
                boolVal   = path == PathStringPool.Get();
                boolVal   = path != PathStringPool.Get();
                boolVal   = path < PathStringPool.Get();
                boolVal   = path <= PathStringPool.Get();
                boolVal   = path > PathStringPool.Get();
                boolVal   = path >= PathStringPool.Get();
                str       = path;
                pathStr   = ((PathString)("./aaa/bbb/ccc"));

                path.GetObjectData(sinfo, default);

                ISerializable            serializable = path;
                IFormattable             formattable  = path;
                IEquatable <PathString>  equatableA   = path;
                IEquatable <string>      equatableB   = path;
                IComparable              comparable   = path;
                IComparable <PathString> comparableA  = path;
                IComparable <string>     comparableB  = path;
            }