aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionRequest.cs
blob: e0a47041c6b9ad37635112623304473827d8e660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Transport.Web;

namespace Tango.MachineStudio.Common.Web
{
    public class DownloadLatestVersionRequest : WebRequestMessage
    {

    }
}
weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
using DeepEqual;
using DeepEqual.Syntax;

namespace Tango.UnitTesting
{
    /// <summary>
    /// Contains several unit testing helper methods.
    /// </summary>
    public static class Helper
    {
        /// <summary>
        /// Gets the absolute path to the specified file name in the solution 'Resources' folder.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <returns></returns>
        public static String GetResourcePath(String fileName)
        {
            return Path.GetFullPath(@"..\..\..\Resources\" + fileName);
        }

        /// <summary>
        /// Gets the absolute path to the 'Resources' folder.
        /// </summary>
        /// <returns></returns>
        public static String GetResourcePath()
        {
            return Path.GetFullPath(@"..\..\..\Resources\");
        }

        /// <summary>
        /// Gets the PMR (Protobuf Messages Repository) path.
        /// </summary>
        /// <returns></returns>
        public static String GetPMRPath()
        {
            return Path.GetFullPath(@"..\..\..\PMR\Messages\");
        }

        /// <summary>
        /// Gets the machine studio exe path.
        /// </summary>
        /// <returns></returns>
        public static String GetMachineStudioPath()
        {
            return Path.GetFullPath(@"..\..\Build\Debug\Tango.MachineStudio.UI.exe");
        }

        /// <summary>
        /// Gets the tango build path.
        /// </summary>
        /// <returns></returns>
        public static String GetBuildPath()
        {
            return Path.GetFullPath(@"..\..\Build\Debug");
        }

        /// <summary>
        /// Gets the SQLite database file path in DB folder.
        /// </summary>
        /// <returns></returns>
        public static String GetSQLiteFilePath()
        {
            return Path.GetFullPath(@"..\..\..\DB\Tango.db");
        }

        /// <summary>
        /// Initializes the logging manager.
        /// </summary>
        public static ConsoleLogger InitializeLogging(bool useConsole = false, [CallerMemberName] string testName = null)
        {
            LogManager.Default.RegisterLogger(new FileLogger(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "logs", "Unit Testing"), "Unit_Testing"));
            if (useConsole)
            {
                var consoleLogger = new ConsoleLogger(testName);
                LogManager.Default.RegisterLogger(consoleLogger);
                return consoleLogger;
            }

            return null;
        }

        /// <summary>
        /// Creates a temporary folder and returns it's path.
        /// </summary>
        /// <returns></returns>
        public static String GetTempFolderPathAppend(String customFolder, [CallerMemberName] string testName = null)
        {
            String tempDirectory = Path.Combine(Path.GetTempPath(), "Twine", "Unit Testing", testName, customFolder);
            Directory.CreateDirectory(tempDirectory);
            return tempDirectory;
        }

        /// <summary>
        /// Creates a temporary folder and returns it's path.
        /// </summary>
        /// <returns></returns>
        public static String GetTempFolderPath([CallerMemberName] string testName = null)
        {
            String tempDirectory = Path.Combine(Path.GetTempPath(), "Twine", "Unit Testing", testName, Path.GetRandomFileName());
            Directory.CreateDirectory(tempDirectory);
            return tempDirectory;
        }

        /// <summary>
        /// Tries to delete folder.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static bool TryDeleteFolder(String path)
        {
            try
            {
                Directory.Delete(path, true);
                return true;
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// Shows the file in explorer.
        /// </summary>
        /// <param name="path">Name of the file/folder.</param>
        public static void ShowInExplorer(String path)
        {
            Process.Start("explorer.exe", string.Format("/select,\"{0}\"", path));
        }

        /// <summary>
        /// Returns true if the two objects are equal by using deep equal.
        /// </summary>
        /// <param name="obj1">First object.</param>
        /// <param name="obj2">Second object.</param>
        /// <returns></returns>
        public static bool IsDeepEqual(Object obj1, Object obj2)
        {
            return obj1.IsDeepEqual(obj2);
        }
    }
}