public void Add(HistoricalDocDto d)
        {
            var key = Base64UrlTextEncoder.Encode(
                new DocumentAggregateKey
            {
                HanziCanonical = d.HanziCanonical,
                Initial        = d.Initial,
                Final          = d.Final,
                Tone           = d.Tone
            }
                .ToByteArray());

            if (!documents.ContainsKey(key))
            {
                documents[key] = new HistoricalDocument()
                {
                    Id = key
                };
            }
            documents[key].Initial        = d.Initial;
            documents[key].Final          = d.Final;
            documents[key].Tone           = d.Tone;
            documents[key].HanziCanonical = d.HanziCanonical;
            documents[key].Buc            = d.Buc;
            documents[key].Yngping        = YngpingBekinUtil.FanqieToYngping(d.Initial, d.Final, d.Tone);
            documents[key].YngpingModern  =
                CikLingUtil.ToYngPingHokchew(GetInitial(d.Initial), GetFinal(d.Final), GetTone(d.Tone));

            var altA      = documents[key].HanziAlternatives;
            var altB      = d.HanziAlternatives;
            var altMerged = altA.Union(altB).Distinct().ToList();

            documents[key].HanziAlternatives.Clear();
            documents[key].HanziAlternatives.AddRange(altMerged);

            var mA      = documents[key].HanziMatchable;
            var mB      = d.HanziMatchable;
            var mMerged = mA.Union(mB).Distinct().ToList();

            documents[key].HanziMatchable.Clear();
            documents[key].HanziMatchable.AddRange(mMerged);

            if (d is CikLingDto)
            {
                var c = d as CikLingDto;
                documents[key].CiklinSource = c.CikLinSourceInfo;
                if (!string.IsNullOrEmpty(c.ZingzeuId))
                {
                    documents[key].ZingzeuId = c.ZingzeuId;
                }
            }

            if (d is DfdDto)
            {
                documents[key].DfdSource = (d as DfdDto).DFDSourceInfo;
            }
        }
Esempio n. 2
0
 public void ToYngPingHokchew_HonorsUoYoConversion(string input, string output)
 {
     CikLingUtil.ToYngPingHokchew(input).Should().Be(output);
 }
Esempio n. 3
0
        public void ToYngPingHokchew_InvalidInitial_Throws(string input)
        {
            Action act = () => CikLingUtil.ToYngPingHokchew(input);

            act.Should().Throw <ArgumentException>();
        }
Esempio n. 4
0
 // TODO: write more test cases
 public void ToYngPingHokchew(string input, string output)
 {
     CikLingUtil.ToYngPingHokchew(input).Should().Be(output);
 }