Ejemplo n.º 1
0
        public void GetLevel2Default_MultiplePossibilities()
        {
            var level1 = new QuotationMark("«", "»", "«", 1, QuotationMarkingSystemType.Normal);
            var level2 = QuoteUtils.GetLevel2Default(level1);

            Assert.AreEqual("“", level2.Open);
            Assert.AreEqual("”", level2.Close);
            Assert.AreEqual("“", level2.Continue);
            Assert.AreEqual(2, level2.Level);
            Assert.AreEqual(QuotationMarkingSystemType.Normal, level2.Type);
        }
Ejemplo n.º 2
0
        public void GetLevel2Possibilities_OnePossibility()
        {
            var level1 = new QuotationMark("»", "«", "»", 1, QuotationMarkingSystemType.Normal);
            var level2Possibilities = QuoteUtils.GetLevel2Possibilities(level1);

            Assert.AreEqual(1, level2Possibilities.Count());
            var level2 = level2Possibilities.First();

            Assert.AreEqual("›", level2.Open);
            Assert.AreEqual("‹", level2.Close);
        }
Ejemplo n.º 3
0
        public void GetLevel2Possibilities_MultiplePossibilities()
        {
            var level1 = new QuotationMark("«", "»", "«", 1, QuotationMarkingSystemType.Normal);
            var level2Possibilities = QuoteUtils.GetLevel2Possibilities(level1);

            Assert.AreEqual(6, level2Possibilities.Count());
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("“") && p.Close.Equals("”") && p.Continue.Equals("«“")));
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("‹") && p.Close.Equals("›") && p.Continue.Equals("«‹")));
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("«") && p.Close.Equals("»") && p.Continue.Equals("««")));
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("„") && p.Close.Equals("“") && p.Continue.Equals("«„")));
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("’") && p.Close.Equals("’") && p.Continue.Equals("«’")));
            Assert.AreEqual(1, level2Possibilities.Count(p => p.Open.Equals("‘") && p.Close.Equals("’") && p.Continue.Equals("«‘")));
        }
Ejemplo n.º 4
0
        public async Task <FulfillmentResponse> FulfillAsync(FulfillmentRequest fulfillmentRequest, IJobberClient jobberClient)
        {
            var quoteNumber     = fulfillmentRequest.GetParameterAsInt(Constants.Variables.QuoteNumber);
            var quoteCollection = await jobberClient.GetQuotesAsync();

            var filteredQuotes = quoteCollection.Quotes.Where(q => q.QuoteNumber == quoteNumber);

            switch (filteredQuotes.Count())
            {
            case 1:
                return(QuoteUtils.BuildResponseFor(filteredQuotes.First()));

            default:
                return(BuildResponseForNoMatchingQuotes(quoteNumber));
            }
        }
        public async Task <FulfillmentResponse> FulfillAsync(FulfillmentRequest fulfillmentRequest, IJobberClient jobberClient)
        {
            var clientName  = fulfillmentRequest.GetParameter(Constants.Variables.ClientName);
            var serviceName = fulfillmentRequest.GetParameter(Constants.Variables.ServiceName);

            var quotesCollection = await jobberClient.GetQuotesAsync();

            var filteredQuotes = quotesCollection.Quotes
                                 .Where(q => q.Client.Name.ContainsIgnoringCase(clientName))
                                 .Where(q => DoesLineItemsMatchUserQuery(q.LineItems, serviceName));

            switch (filteredQuotes.Count())
            {
            case 0:
                return(BuildResponseForNoMatchingQuotes());

            case 1:
                return(QuoteUtils.BuildResponseFor(filteredQuotes.First()));

            default:
                return(BuildResponseForMuiltipleMatchesFor(fulfillmentRequest, filteredQuotes));
            }
        }
 public void Guess_AllFirstLevelQuoteSystemsWithMultipleSecondLevelPossibilitiesAndDialogueQuotesWithHighlyConsistentData_CorrectlyIdentifiesSystemWithUncertainty()
 {
     foreach (var quoteSystem in QuoteSystem.UniquelyGuessableSystems.Where(qs => !String.IsNullOrEmpty(qs.QuotationDashMarker) &&
                                                                            qs.NormalLevels.Count == 1 && QuoteUtils.GetLevel2Possibilities(qs.FirstLevel).Count() > 1))
     {
         RunTest(quoteSystem, true, false, false);
     }
 }
 public void Guess_AllSinglePossibilityMultipleLevelQuoteSystemsWithHighlyConsistentData_CorrectlyIdentifiesSystemWithoutCertainty()
 {
     foreach (var quoteSystem in QuoteSystem.UniquelyGuessableSystems.Where(qs => String.IsNullOrEmpty(qs.QuotationDashMarker) &&
                                                                            qs.NormalLevels.Count == 3 && QuoteUtils.GetLevel2Possibilities(qs.FirstLevel).Count() == 1))
     {
         RunTest(quoteSystem, true, false, false);
     }
 }
Ejemplo n.º 8
0
 public void Guess_MostSinglePossibilityMultipleLevelQuoteSystemsWithHighlyConsistentData_CorrectlyIdentifiesSystemWithCertainty()
 {
     foreach (var quoteSystem in QuoteSystem.UniquelyGuessableSystems.Where(qs => String.IsNullOrEmpty(qs.QuotationDashMarker) &&
                                                                            qs.NormalLevels.Count == 3 && QuoteUtils.GetLevel2Possibilities(qs.FirstLevel).Length == 1 &&
                                                                            qs.Name != "מֵירְכָאוֹת (Curly) with levels 2 (’/‘) and 3."))
     {
         RunTest(quoteSystem, true, false, true);
     }
 }
Ejemplo n.º 9
0
        private void SetupQuoteMarksComboBoxes(QuoteSystem currentSystem)
        {
            foreach (var control in m_pnlLevels.Controls)
            {
                var cb = control as ComboBox;
                if (cb != null)
                {
                    cb.Items.Clear();
                    cb.Items.AddRange(QuoteUtils.AllDefaultSymbols());
                }
            }

            foreach (var level in m_project.QuoteSystem.NormalLevels)
            {
                if (level.Level == 1)
                {
                    m_chkPairedQuotations.Checked = !string.IsNullOrEmpty(level.Open);
                }

                if (m_chkPairedQuotations.Checked)
                {
                    switch (level.Level)
                    {
                    case 1:
                        m_cbLevel1Begin.Text    = BlankBecomesNone(level.Open);
                        m_cbLevel1Continue.Text = BlankBecomesNone(level.Continue);
                        m_cbLevel1End.Text      = BlankBecomesNone(level.Close);
                        break;

                    case 2:
                        m_cbLevel2Begin.Text    = BlankBecomesNone(level.Open);
                        m_cbLevel2Continue.Text = BlankBecomesNone(level.Continue);
                        m_cbLevel2End.Text      = BlankBecomesNone(level.Close);
                        break;

                    case 3:
                        m_cbLevel3Begin.Text    = BlankBecomesNone(level.Open);
                        m_cbLevel3Continue.Text = BlankBecomesNone(level.Continue);
                        m_cbLevel3End.Text      = BlankBecomesNone(level.Close);
                        break;
                    }
                }

                EnablePairedQuotes(m_chkPairedQuotations.Checked);
            }

            var quotationDashMarker = currentSystem.QuotationDashMarker;

            m_chkDialogueQuotations.Checked = !String.IsNullOrEmpty(quotationDashMarker);
            m_cboQuotationDash.Items.Clear();
            m_cboQuotationDash.Items.Add(string.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuotationDash", "Quotation dash ({0})"), "U+2015"));
            m_cboQuotationDash.Items.Add(string.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.EmDash", "Em-dash ({0})"), "U+2014"));
            m_cboQuotationDash.Items.Add(string.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.Colon", "Colon ( {0} )"), ":"));
            switch (quotationDashMarker)
            {
            case "\u2015": m_cboQuotationDash.SelectedIndex = 0; break;

            case "\u2014": m_cboQuotationDash.SelectedIndex = 1; break;

            case ":": m_cboQuotationDash.SelectedIndex = 2; break;

            default: m_cboQuotationDash.Text = quotationDashMarker; break;
            }

            m_cboEndQuotationDash.Items.Clear();
            m_cboEndQuotationDash.Items.Add(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.EndQuotationDashWithParagraphOnly", "End of paragraph (only)"));
            if (QuotationDashSelected)
            {
                m_cboEndQuotationDash.Items.Add(SameAsStartDashText);
                m_endMarkerComboIncludesSameAsStartDashTextOption = true;
            }
#if HANDLE_SENTENCE_ENDING_PUNCTUATION_FOR_DIALOGUE_QUOTES
            m_cboEndQuotationDash.Items.Add(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.SentenceEndingPunctuation", "Sentence-ending punctuation"));
#endif //HANDLE_SENTENCE_ENDING_PUNCTUATION_FOR_DIALOGUE_QUOTES

            var quotationDashEndMarker = currentSystem.QuotationDashEndMarker;
            if (string.IsNullOrEmpty(quotationDashEndMarker))
            {
                m_cboEndQuotationDash.SelectedIndex = 0;
            }
            else if (m_endMarkerComboIncludesSameAsStartDashTextOption && quotationDashEndMarker == quotationDashMarker)
            {
                m_cboEndQuotationDash.SelectedIndex = 1;
            }
#if HANDLE_SENTENCE_ENDING_PUNCTUATION_FOR_DIALOGUE_QUOTES
            else if (quotationDashEndMarker == QuoteUtils.kSentenceEndingPunctuation)
            {
                m_cboEndQuotationDash.SelectedIndex = m_endMarkerComboIncludesSameAsStartDashTextOption ? 2 : 1;
            }
#endif //HANDLE_SENTENCE_ENDING_PUNCTUATION_FOR_DIALOGUE_QUOTES
            else
            {
                m_cboEndQuotationDash.Text = quotationDashEndMarker;
            }
        }
Ejemplo n.º 10
0
        private void SetupQuoteMarksComboBoxes(QuoteSystem currentSystem)
        {
//			m_comboQuoteMarks.Items.AddRange(QuoteSystem.AllUniqueFirstLevelSystems.ToArray());
//			m_comboQuoteMarks.SelectedItem = currentSystem.GetCorrespondingFirstLevelQuoteSystem();

            foreach (var control in m_pnlLevels.Controls)
            {
                var cb = control as ComboBox;
                if (cb != null)
                {
                    cb.Items.Clear();
                    cb.Items.AddRange(QuoteUtils.AllDefaultSymbols());
                }
            }

            foreach (var level in m_project.QuoteSystem.NormalLevels)
            {
                switch (level.Level)
                {
                case 1:
                    m_cbLevel1Begin.Text    = BlankBecomesNone(level.Open);
                    m_cbLevel1Continue.Text = BlankBecomesNone(level.Continue);
                    m_cbLevel1End.Text      = BlankBecomesNone(level.Close);
                    break;

                case 2:
                    m_cbLevel2Begin.Text    = BlankBecomesNone(level.Open);
                    m_cbLevel2Continue.Text = BlankBecomesNone(level.Continue);
                    m_cbLevel2End.Text      = BlankBecomesNone(level.Close);
                    break;

                case 3:
                    m_cbLevel3Begin.Text    = BlankBecomesNone(level.Open);
                    m_cbLevel3Continue.Text = BlankBecomesNone(level.Continue);
                    m_cbLevel3End.Text      = BlankBecomesNone(level.Close);
                    break;
                }
            }

            var quotationDashMarker = currentSystem.QuotationDashMarker;

            m_chkDialogueQuotations.Checked = !String.IsNullOrEmpty(quotationDashMarker);
            m_cboQuotationDash.Items.Clear();
            m_cboQuotationDash.Items.Add(string.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuotationDash", "Quotation dash ({0})"), "U+2015"));
            m_cboQuotationDash.Items.Add(string.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.EmDash", "Em-dash ({0})"), "U+2014"));
            switch (quotationDashMarker)
            {
            case "\u2015": m_cboQuotationDash.SelectedIndex = 0; break;

            case "\u2014": m_cboQuotationDash.SelectedIndex = 1; break;

            default: m_cboQuotationDash.Text = quotationDashMarker; break;
            }

            m_cboEndQuotationDash.Items.Clear();
            m_cboEndQuotationDash.Items.Add(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.EndQuotationDashWithParagraphOnly", "End of paragraph (only)"));
            m_cboEndQuotationDash.Items.Add(SameAsStartDashText);

            var quotationDashEndMarker = currentSystem.QuotationDashEndMarker;

            if (string.IsNullOrEmpty(quotationDashEndMarker))
            {
                m_cboEndQuotationDash.SelectedIndex = 0;
            }
            else if (quotationDashEndMarker == quotationDashMarker)
            {
                m_cboEndQuotationDash.SelectedIndex = 1;
            }
            else
            {
                m_cboEndQuotationDash.Text = quotationDashEndMarker;
            }
        }