public void ComboHandler_CreateCoreMorphItemBasedOnSandboxCurrentState_DeletedSense_DoesNotThrow()
{
// Make an entry with a morph and a sense with no MSA.
var entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create();
var morph = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create();
entry.LexemeFormOA = morph;
morph.Form.SetVernacularDefaultWritingSystem("kick");
morph.MorphTypeRA =
Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot);
// Set up first sense
var sense = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create();
entry.SensesOS.Add(sense);
sense.Gloss.SetAnalysisDefaultWritingSystem("silly");
// Make an analysis from that MSA.
var wf = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create();
wf.Form.SetVernacularDefaultWritingSystem("kick");
var wa = Cache.ServiceLocator.GetInstance<IWfiAnalysisFactory>().Create();
wf.AnalysesOC.Add(wa);
var mb = Cache.ServiceLocator.GetInstance<IWfiMorphBundleFactory>().Create();
wa.MorphBundlesOS.Add(mb);
mb.SenseRA = sense;
mb.MorphRA = morph;
// Set up second sense
var sense2 = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create();
entry.SensesOS.Add(sense2);
sense2.Gloss.SetAnalysisDefaultWritingSystem("problem");
// Make a sandbox and sut
InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject,
Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze);
using(var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo))
{
var mockList = new MockComboHandler();
sandbox.m_ComboHandler = mockList;
// Merge the first sense into the second (invalidating analysis and sandbox cache)
using(var handler = GetComboHandler(sandbox, InterlinLineChoices.kflidLexEntries, 0))
{
// wipe out the sense that the morph bundle was based on.
sense2.MergeObject(sense, true);
Assert.AreEqual(entry.SensesOS[0], sense2);
Assert.DoesNotThrow(()=>
{
// ReSharper disable once UnusedVariable - Assignment is SUT
var i = handler.IndexOfCurrentItem;
});
}
}
}