Exemplo n.º 1
0
        public void TestPasswordEncoding()
        {
            rcHelper rc    = new rcHelper();
            string   pass  = "******";
            string   ePass = rc.EncodePassword(pass);

            ePass = rc.DecodePassword(ePass);
            Assert.AreEqual(ePass, pass);
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            //Set working directory to match RedditCrawler's
            string s = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\RedditCrawler");

            if (!Directory.Exists(s))
            {
                Directory.CreateDirectory(s);
            }
            Directory.SetCurrentDirectory(s);

            //Initialize helper classes
            rcHelper  rc   = new rcHelper();
            RCDetails data = new RCDetails();

            //Initial code for populating textboxes with existing criteria
            #region populate fields
            try
            {
                //Toggle toast toggle button and field auto-fill based on existing criteria
                if (File.Exists(System.IO.Path.Combine(Directory.GetCurrentDirectory().ToString() + jsonFilePath)))
                {
                    var datRaw = File.ReadAllText(System.IO.Path.Combine(Directory.GetCurrentDirectory().ToString() + jsonFilePath));
                    data = JsonConvert.DeserializeObject <RCDetails>(datRaw);
                    if (data.toast == "yes")
                    {
                        tbtnToast.IsChecked = true;
                    }
                    if (data.sub != null)
                    {
                        txtSubreddit.Text = data.sub;
                    }
                    if (data.email != null)
                    {
                        txtEmail.Text = rc.DecodePassword(data.email);
                    }
                    if (data.ePass != null)
                    {
                        pwdEmail.Password = rc.DecodePassword(data.ePass);
                    }
                    if (data.searchCriteria.Count > 0)
                    {
                        foreach (string s2 in data.searchCriteria)
                        {
                            //Ensures no new line is created at end of list
                            if (data.searchCriteria.IndexOf(s2) != data.searchCriteria.Count - 1)
                            {
                                rtfSearchTerms.AppendText(s2 + "\n");
                            }
                            else
                            {
                                rtfSearchTerms.AppendText(s2);
                            }
                        }
                    }
                }
            }
            //Generic exception handling
            catch (Exception ex)
            {
                rc.DebugLog(ex);
            }
            #endregion
        }