Esempio n. 1
0
        public void Test_EditEntryObjectException_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => h.EditEntry(e, false));
        }
Esempio n. 2
0
        public void Remove_FromEmpty_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => h.RemoveEntry("DuckDuckGo", false, false));
        }
Esempio n. 3
0
        public void Check_KeyExists_NotImplemented()
        {
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            // Key exists must be implemented by derived classes
            Assert.ThrowsException <System.NotImplementedException>(() => h.KeyExists(null, null, false));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void write(long logIndex, org.neo4j.causalclustering.core.consensus.log.RaftLogEntry entry) throws java.io.IOException
        public virtual void Write(long logIndex, RaftLogEntry entry)
        {
            lock (this)
            {
                EntryRecord.write(OrCreateWriter, _contentMarshal, logIndex, entry.Term(), entry.Content());
            }
        }
Esempio n. 5
0
        public void GetList_Test_EntryRecord()
        {
            EntryRecord         h    = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            List <EntryElement> list = new List <EntryElement>();
            EntryElement        e1   = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);
            EntryElement        e2   = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo2", CompareBy.AlphabetTitle);
            EntryElement        e3   = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo3", CompareBy.AlphabetTitle);
            EntryElement        e4   = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo4", CompareBy.AlphabetTitle);

            Assert.AreEqual(h.GetList().Count, list.Count, "List size 0 expected");

            h.AddEntry(e1, false);
            h.AddEntry(e2, false);
            h.AddEntry(e3, false);
            h.AddEntry(e4, false);


            list.Add(e1);
            list.Add(e2);
            list.Add(e3);
            list.Add(e4);

            Assert.AreNotSame(h.GetList(), list, "Expected Object and Actual object are the same");
            Assert.AreEqual(h.GetList().Count, list.Count, "List size 4 expected");
            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreSame(h.GetList()[i], list[i], "Expected Object and Actual object are not the same");
            }
        }
Esempio n. 6
0
        public void Test_GetEntry_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);

            Assert.AreSame(h.GetEntry(0), e, "Expected and Actual Object mismatch");
        }
Esempio n. 7
0
        public void Add_EmptyTitleTo_List()
        {
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            h.AddEntry("http://www.duckduckgo.com", "", false);
            Assert.AreEqual(h.GetList()[0].Title, "http://www.duckduckgo.com", "Title mismatch in Add_ToEmpty_History");
            Assert.AreEqual(h.GetList()[0].Url, "http://www.duckduckgo.com", "URL mismatch in ADD_ToEmpty_History");
            Assert.AreEqual(h.GetList().Count, 1, "List Size mismatch");
        }
Esempio n. 8
0
        public void Test_GetUrl_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);

            Assert.AreEqual(h.GetUrl("DuckDuckGo"), "http://www.duckduckgo.com", "Expected and Actual URL mismatch");
        }
Esempio n. 9
0
        public ActionResult AddNewEntry(int cameraid)
        {
            try
            {
                _logger.LogInformation("AddNewEntry() called from: " + HttpContext.Connection.RemoteIpAddress.ToString());
                DateTime dateTime = DateTime.UtcNow.ToTimezone(Configuration["Timezone"]);

                lock (lockEntryObject)
                {
                    EntryRecord entryRecord = new EntryRecord();
                    entryRecord.Timestamp = dateTime;
                    entryRecord.CameraId  = cameraid;

                    Context.EntryRecords.Add(entryRecord);

                    var entryCount = Context.EntryCounts
                                     .Where(x => x.CameraId == cameraid && x.Date == dateTime.Date)
                                     ?.Select(x => x)
                                     ?.FirstOrDefault();

                    if (entryCount == null)
                    {
                        EntryCount newEntryCount = new EntryCount();
                        newEntryCount.Date     = dateTime.Date;
                        newEntryCount.CameraId = cameraid;
                        newEntryCount.Count    = 1;

                        Context.EntryCounts.Add(newEntryCount);
                        Context.SaveChangesAsync();
                    }
                    else
                    {
                        entryCount.Count = entryCount.Count + 1;
                        Context.SaveChangesAsync();
                    }

                    SignalRHubConnection.GetInstance(Configuration["SignalRHubUrl"])
                    .SendAsync("BroadcastEntry", cameraid);
                }

                return(new JsonResult(new
                {
                    respcode = ResponseCodes.Successful,
                }));
            }
            catch (Exception e)
            {
                _logger.LogError($"Generic exception handler invoked. {e.Message}: {e.StackTrace}");

                return(new JsonResult(new
                {
                    respcode = ResponseCodes.SystemError,
                    description = ResponseCodes.SystemError.DisplayName(),
                    Error = e.Message
                }));
            }
        }
Esempio n. 10
0
        public void Remove_EntryFrom_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);
            Assert.AreSame(h.GetList()[0], e);
            h.RemoveEntry("DuckDuckGo", false, false);
            Assert.AreEqual(h.GetList().Count, 0);
        }
Esempio n. 11
0
        public void Test_GetTime_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);

            string time = e.AccessTime.ToString();

            Assert.AreEqual(h.GetTime("DuckDuckGo").ToString(), time, "Expected and Actual Time string mismatch");
        }
Esempio n. 12
0
        public void Test_EditEntryTitle_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);
            Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch");

            h.EditEntryTitle("DuckDuckGo", "DifferentTitle", false);
            Assert.AreEqual(h.GetList()[0].Title, "DifferentTitle", "Expected and Actual Title mismatch");
        }
Esempio n. 13
0
        public void Clear_EntryRecord_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);
            Assert.AreSame(h.GetList()[0], e, "Expected Object and Actual object are not the same");
            Assert.AreEqual(h.GetList().Count, 1, "List size of 1 expected");
            h.ClearList(false);
            Assert.AreEqual(h.GetList().Count, 0, "List size of 0 expected");
        }
Esempio n. 14
0
        public void Test_EventAddEntry_EntryRecord()
        {
            bool        eventTriggered = false;
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            h.EntryChanged += delegate { eventTriggered = true; };
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            Assert.AreEqual(eventTriggered, false, "The event should not have triggered");
            h.AddEntry(e, false);
            Assert.AreEqual(eventTriggered, true, "The event should have triggered");
        }
Esempio n. 15
0
        public void Test_EditEntryObject_EntryRecord()
        {
            EntryRecord  h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.AddEntry(e, false);
            Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch");
            Assert.AreEqual(h.GetList()[0].Url, "http://www.duckduckgo.com", "Expected and Actual Title mismatch");

            EntryElement u = new EntryElement("http://www.google.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            h.EditEntry(u, false);
            Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch");
            Assert.AreEqual(h.GetList()[0].Url, "http://www.google.com", "Expected and Actual Title mismatch");
            Assert.AreEqual(h.GetList().Count, 1, "List size of 1 expected");
        }
Esempio n. 16
0
        public void Test_GetIndex_EntryRecord()
        {
            EntryRecord  h  = new EntryRecord("Test", CompareBy.AlphabetTitle, false);
            EntryElement e1 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);
            EntryElement e2 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo2", CompareBy.AlphabetTitle);
            EntryElement e3 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo3", CompareBy.AlphabetTitle);
            EntryElement e4 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo4", CompareBy.AlphabetTitle);

            h.AddEntry(e1, false);
            h.AddEntry(e2, false);
            h.AddEntry(e3, false);
            h.AddEntry(e4, false);

            Assert.AreEqual(h.GetIndex("DuckDuckGo3"), 2, "Expected and Actual index mismatch");
            Assert.AreEqual(h.GetIndex("DuckDuckGo4"), 3, "Expected and Actual index mismatch");
            Assert.AreEqual(h.GetIndex("DuckDuckGo"), 0, "Expected and Actual index mismatch");
            Assert.AreEqual(h.GetIndex("DuckDuckGo2"), 1, "Expected and Actual index mismatch");
        }
Esempio n. 17
0
        public void Test_EventExpectedParams_EntryRecord()
        {
            object             sentFrom = null;
            EntryRecordChanged args     = null;
            bool        eventTriggered  = false;
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            h.EntryChanged += delegate(object sender, EntryRecordChanged e) { eventTriggered = true; sentFrom = sender; args = e; };
            EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle);

            Assert.AreEqual(eventTriggered, false, "The event should not have triggered");
            Assert.AreSame(sentFrom, null, "The event should be null");
            Assert.AreSame(args, null, "The event should be null");
            h.AddEntry(e, false);
            Assert.AreEqual(eventTriggered, true, "The event should have triggered");
            Assert.AreSame(sentFrom, h, "h should be the sender object");
            Assert.AreSame(args.EntryKey, e.Title, "Entry Key should be the title");
            Assert.AreEqual(args.AddRemUpd, ARU.Added, "AddRemUpd should be Added");
            Assert.AreEqual(args.Path, "Test", "Path should match path used when instantiating h");
            Assert.AreEqual(args.WriteFile, false, "WriteFile should be false");
        }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkedInMiner.Tags.TagParser"/> class.
 /// </summary>
 /// <param name='html'>
 /// Matched html to be parsed.
 /// </param>
 /// <param name='logger'>
 /// Logger object
 /// </param>
 public TagParser(string html, Logger logger)
 {
     _html        = html;
     _logger      = logger;
     _entryRecord = new EntryRecord(_logger);
 }
Esempio n. 19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: State run() throws java.io.IOException, DamagedLogStorageException, DisposedException
        internal virtual State Run()
        {
            State state = new State();
            SortedDictionary <long, File> files = _fileNames.getAllFiles(_fileSystem, _log);

            if (Files.SetOfKeyValuePairs().Empty)
            {
                state.Segments = new Segments(_fileSystem, _fileNames, _readerPool, emptyList(), _contentMarshal, _logProvider, -1);
                state.Segments.rotate(-1, -1, -1);
                state.Terms = new Terms(-1, -1);
                return(state);
            }

            IList <SegmentFile> segmentFiles = new List <SegmentFile>();
            SegmentFile         segment      = null;

            long expectedVersion       = Files.firstKey();
            bool mustRecoverLastHeader = false;
            bool skip = true;               // the first file is treated the same as a skip

            foreach (KeyValuePair <long, File> entry in Files.SetOfKeyValuePairs())
            {
                long          fileNameVersion = entry.Key;
                File          file            = entry.Value;
                SegmentHeader header;

                CheckVersionSequence(fileNameVersion, expectedVersion);

                try
                {
                    header = LoadHeader(_fileSystem, file);
                    CheckVersionMatches(header.Version(), fileNameVersion);
                }
                catch (EndOfStreamException e)
                {
                    if (Files.lastKey() != fileNameVersion)
                    {
                        throw new DamagedLogStorageException(e, "Intermediate file with incomplete or no header found: %s", file);
                    }
                    else if (Files.Count == 1)
                    {
                        throw new DamagedLogStorageException(e, "Single file with incomplete or no header found: %s", file);
                    }

                    /* Last file header must be recovered by scanning next-to-last file and writing a new header based on that. */
                    mustRecoverLastHeader = true;
                    break;
                }

                segment = new SegmentFile(_fileSystem, file, _readerPool, fileNameVersion, _contentMarshal, _logProvider, header);
                segmentFiles.Add(segment);

                if (segment.Header().prevIndex() != segment.Header().prevFileLastIndex())
                {
                    _log.info(format("Skipping from index %d to %d.", segment.Header().prevFileLastIndex(), segment.Header().prevIndex() + 1));
                    skip = true;
                }

                if (skip)
                {
                    state.PrevIndex = segment.Header().prevIndex();
                    state.PrevTerm  = segment.Header().prevTerm();
                    skip            = false;
                }

                expectedVersion++;
            }

            Debug.Assert(segment != null);

            state.AppendIndex = segment.Header().prevIndex();
            state.Terms       = new Terms(segment.Header().prevIndex(), segment.Header().prevTerm());

            using (IOCursor <EntryRecord> cursor = segment.GetCursor(segment.Header().prevIndex() + 1))
            {
                while (cursor.next())
                {
                    EntryRecord entry = cursor.get();
                    state.AppendIndex = entry.LogIndex();
                    state.Terms.append(state.AppendIndex, entry.LogEntry().term());
                }
            }

            if (mustRecoverLastHeader)
            {
                SegmentHeader header = new SegmentHeader(state.AppendIndex, expectedVersion, state.AppendIndex, state.Terms.latest());
                _log.warn("Recovering last file based on next-to-last file. " + header);

                File file = _fileNames.getForVersion(expectedVersion);
                WriteHeader(_fileSystem, file, header);

                segment = new SegmentFile(_fileSystem, file, _readerPool, expectedVersion, _contentMarshal, _logProvider, header);
                segmentFiles.Add(segment);
            }

            state.Segments = new Segments(_fileSystem, _fileNames, _readerPool, segmentFiles, _contentMarshal, _logProvider, segment.Header().version());

            return(state);
        }
Esempio n. 20
0
        public override void Awake()
        {
            base.Awake();
            if (nomalSprite == null)
            {
                nomalSprite = facialPhoto.sprite;
            }
            IdText.input.onValueChanged.AddListener((s) =>
            {
                if (VerifyUtils.IsNumber(s))
                {
                    personnel.ID  = int.Parse(s);
                    IdText.Verify = true;
                    return;
                }
                IdText.Verify = false;
            });
            IdCardText.input.onValueChanged.AddListener((s) =>
            {
                if (VerifyUtils.IsIDCard(s))
                {
                    personnel.IDCard  = s;
                    IdCardText.Verify = true;
                    return;
                }
                IdCardText.Verify = false;
            });
            archivalPhotoUpdateButton.onClick.AddListener(() =>
            {
                if (personnel != null)
                {
                    string file = Win32API.GetOpenFileName();
                    if (file != null)
                    {
                        archivalPhotoUpdateFileName = file;
                    }
                }
            });
            archivalPhotoButton.onClick.AddListener(() =>
            {
                if (personnel != null)
                {
                    if (!Kernel.Current.Image.View(archivalPhotoUpdateFileName))
                    {
                        Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "打开失败!", "图片不存在或被其他程序占用无法打开.");
                    }
                }
            });
            FacialPhotoButtion.onClick.AddListener(() =>
            {
                Sprite s = Kernel.Current.Image.Load(nomalSprite.texture.width, nomalSprite.texture.height);
                if (s != null)
                {
                    facialPhoto.sprite = s;
                }
            });
            PhoneText.input.onValueChanged.AddListener((s) =>
            {
                if (s?.Length <= 20)
                {
                    PhoneText.Verify = true;
                    personnel.Phone  = s;
                    return;
                }
                PhoneText.Verify = false;
            });
            UpdateToSql.onClick.AddListener(() =>
            {
                switch (state)
                {
                case InfoFormWorkMode.ViewAndModifiy:
                    {
                        UpdateImage();
                        Debug.Log(personnel.ArchivalPhoto);
                        Debug.Log(personnel.FacialPhoto);
                        Kernel.Current.Sql.UpdateEntity(personnel);
                        Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "修改完成", "修改成功");
                    }
                    break;

                case InfoFormWorkMode.CreateNew:
                    {
                        if (Kernel.Current.Sql.LoadEntity <Personnel>(personnel.ID) == null)
                        {
                            Kernel.Current.Desktop.OpenNew <TextBoxForm>().SetCallback("请输入人员入职信息", (x) =>
                            {
                                EntryRecord entryRecord = new EntryRecord();
                                entryRecord.Info        = x;
                                entryRecord.Time        = DateTime.Now;
                                entryRecord.PersonnelID = personnel.ID;
                                Kernel.Current.Sql.Insert(entryRecord);
                                UpdateImage();
                                Kernel.Current.Sql.InsertEntity(personnel);
                                Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "修改完成", "修改成功");
                            }, null);
                        }
                        else
                        {
                            Kernel.Current.Desktop.OpenNew <DialogForm>().SetDialog(null, "此编号已存在", "请尝试其他编号");
                        }
                    }
                    break;

                default:
                    break;
                }
            });
            delete.onClick.AddListener(() =>
            {
                Kernel.Current.Desktop.OpenNew <TextBoxForm>().SetCallback("添加此人员离职信息.", x =>
                {
                    Kernel.Current.Desktop.OpenNew <YesOrNoForm>().SetDialog(() =>
                    {
                        TurnoverRecord turnoverRecord = new TurnoverRecord();
                        turnoverRecord.Info           = x;
                        turnoverRecord.PersonnelID    = personnel.ID;
                        turnoverRecord.Time           = DateTime.Now;
                        Kernel.Current.Sql.Insert(turnoverRecord);
                        Kernel.Current.Sql.DeleteEntity(personnel);
                    }, null, "确认操作", "确认执行吗?");
                }, null);
            });
            SetWorkMode(InfoFormWorkMode.ViewAndModifiy);
        }
Esempio n. 21
0
        public void Test_EditEntryParamsException_EntryRecord()
        {
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => h.EditEntry("DuckDuckGo", "DifferentTitle", "http://www.google.com", false));
        }
Esempio n. 22
0
        public static async Task Main(string[] args)
        {
            // Set Up App Info
            var app = new CommandLineApplication();

            app.Name        = "Social Media Randomizer - CSV";
            app.Description = "This tool will pick a random entry from a csv file.";
            app.HelpOption("-?|-h|--help");

            // Set up Options/Parameters
            CommandOption entriesOption = app.Option <string>("-e|--entries <filePath>", "This is the path where the CSV file with the entries are located.",
                                                              CommandOptionType.SingleValue);

            CommandOption configOption = app.Option <string>("-c|--config <filePath>", "This is the path where the CSV file with the configuration for entry types & weights are located.",
                                                             CommandOptionType.SingleValue);

            CommandOption shuffleCountOption = app.Option <int>("-s|--shuffle <count>", "This is number of times the list will be shuffled before an entry is chosen. Default is 10.",
                                                                CommandOptionType.SingleValue);

            // Set up what happens when the App Runs
            app.OnExecuteAsync(async cancellationToken =>
            {
                // Check for Options/Parameters
                if (!entriesOption.HasValue() || !File.Exists(entriesOption.Value()))
                {
                    Utilities.Log("❌ Please provide a valid file for the list of entries.", ConsoleColor.Red);
                    return(400);
                }

                if (!configOption.HasValue() || !File.Exists(configOption.Value()))
                {
                    Utilities.Log("❌ Please provide a valid file for your configuration.", ConsoleColor.Red);
                    return(400);
                }

                int shuffleCount = shuffleCountOption.HasValue() ? Convert.ToInt32(shuffleCountOption.Value()) : 10;

                // Get Config & Data from CSV Files
                List <EntryWeight> config  = CsvParser.GetWeights(configOption.Value());
                List <EntryRecord> entries = CsvParser.GetEntries(entriesOption.Value());

                // Apply Weight to Entries
                var weightedEntries = new List <EntryRecord>();

                foreach (EntryRecord entry in entries)
                {
                    int?multiplier = config.FirstOrDefault(c => c.Id == entry.EntryTypeId)?.NumberOfEntries;

                    if (multiplier == null)
                    {
                        Utilities.Log($"❌ No Config Entry Found for Id: {entry.EntryTypeId}", ConsoleColor.Red);
                        Utilities.LogWithKeyInput("Enter any key to exit ...", ConsoleColor.Gray);
                        return(400);
                    }

                    weightedEntries.AddRange(Enumerable.Range(0, multiplier.Value).Select(e => entry).ToList());
                }

                // Shuffle Entries
                Utilities.Log($"Shuffling {weightedEntries.Count} Entries\n", ConsoleColor.DarkGreen);

                for (int i = 0; i < shuffleCount; i++)
                {
                    weightedEntries = weightedEntries.Shuffle().ToList();
                }

                // Pick Random Entry
                EntryRecord winner       = weightedEntries.PickRandom(1).Single();
                EntryWeight winnerSource = config.First(c => c.Id == winner.EntryTypeId);

                Utilities.Log("--------------------------------------------------", ConsoleColor.DarkCyan);
                Utilities.Log(">>                 Winner Found                 <<", ConsoleColor.DarkCyan);
                Utilities.Log($">>{" ",46}<<", ConsoleColor.DarkCyan);
                Utilities.Log($">>  Winner       : {winner.Participant,-28} <<", ConsoleColor.DarkCyan);
                Utilities.Log($">>  Entry Source : {winnerSource.Source,-28} <<", ConsoleColor.DarkCyan);
                Utilities.Log($">>  Entry Method : {winnerSource.TypeOfEntry,-28} <<", ConsoleColor.DarkCyan);
                Utilities.Log($">>{" ",46}<<", ConsoleColor.DarkCyan);
                Utilities.Log("--------------------------------------------------\n", ConsoleColor.DarkCyan);

                return(200);
            });

            // Run the App
            try
            {
                Utilities.Log(">> Initiating the Randomizer\n", ConsoleColor.DarkGreen);
                await app.ExecuteAsync(args);

                Utilities.LogWithKeyInput("Enter any key to exit ...", ConsoleColor.Gray);
            }
            catch (CommandParsingException ex)
            {
                Utilities.Log($"❌ An error has occurred with your command line arguments: {ex.Message}", ConsoleColor.Red);
                Utilities.LogWithKeyInput("Enter any key to exit ...", ConsoleColor.Gray);
            }
            catch (Exception ex)
            {
                Utilities.Log($"❌ An exception was thrown: {ex.Message}", ConsoleColor.Red);
                Utilities.LogWithKeyInput("Enter any key to exit ...", ConsoleColor.Gray);
            }
        }
Esempio n. 23
0
        public void Test_GetIndexException_EntryRecord()
        {
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            Assert.AreEqual(h.GetIndex("DuckDuckGo"), -1, "This index wasnt -1");
        }
Esempio n. 24
0
        public void Test_GetEntryException_EntryRecord()
        {
            EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false);

            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => h.GetEntry(0));
        }