Skip to content

Commit abc7267

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 449eb42 + b22fb5e commit abc7267

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,20 @@ To publish and consume LCModel through local sources:
6060
```bash
6161
(. environ && cd artifacts/Debug/net461/ && ICU_DATA="IcuData/icudt54l" nunit-console SIL.LCModel*Tests.dll )
6262
```
63+
64+
**On Windows with ReSharper**
65+
66+
Open the solution in Visual Studio and run them all there. Right-click the solution and choose Run Unit Tests.
67+
68+
**On Windows without ReSharper**
69+
70+
To run the tests for a single test dll:
71+
1. Go to the liblcm directory.
72+
2. Execute: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe"
73+
Note: Running the tests after building the solution from inside VS resulted in a BadImageFormatException.
74+
Running the tests after building from the cmd prompt worked.
75+
3. Go to the liblcm\artifacts\Debug directory.
76+
4. Execute: "..\..\packages\NUnit.ConsoleRunner.3.9.0\tools\nunit3-console.exe" SIL.LCModel.Tests.dll
77+
(Or specify one of the other SIL.LCModel*Tests.dll)
78+
5. To debug the tests from Visual Studio; Immediately after the tests have started
79+
running "Attach to Process..." and select 'nunit-agent.exe'.

src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,19 @@ internal partial class ConstituentChartCellPartRepository
366366
/// </summary>
367367
public IEnumerable<IConstituentChartCellPart> InstancesWithChartCellColumn(ICmPossibility target)
368368
{
369-
return AllInstances().Where(cccp => cccp.ColumnRA == target);
369+
((ICmObjectRepositoryInternal)m_cache.ServiceLocator.ObjectRepository).EnsureCompleteIncomingRefsFrom(
370+
ConstituentChartCellPartTags.kflidColumn);
371+
SimpleBag<ICmObject> chartCells = new SimpleBag<ICmObject>();
372+
foreach (IReferenceSource referrer in target.ReferringObjects)
373+
{
374+
if ((referrer as CmObject).ClassID != 5123 /* "DsConstChart" */)
375+
{
376+
if (referrer.RefersTo(target, ConstituentChartCellPartTags.kflidColumn))
377+
chartCells.Add(referrer.Source);
378+
}
379+
}
380+
381+
return chartCells.Distinct().Cast<IConstituentChartCellPart>();
370382
}
371383
}
372384
#endregion

tests/SIL.LCModel.Tests/Infrastructure/Impl/RepositoryTests.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2009-2013 SIL International
1+
// Copyright (c) 2009-2013 SIL International
22
// This software is licensed under the LGPL, version 2.1 or later
33
// (http://www.gnu.org/licenses/lgpl-2.1.html)
44
//
@@ -260,6 +260,40 @@ private ILexSense AddSense(ILexEntry entry, string gloss)
260260
}
261261
}
262262

263+
#region ConstituentChartCellPartRepository Tests
264+
/// ----------------------------------------------------------------------------------------
265+
/// <summary>
266+
/// Class to test additions to ConstituentChartCellPartRepository functionality.
267+
/// </summary>
268+
/// ----------------------------------------------------------------------------------------
269+
[TestFixture]
270+
public class ConstituentChartCellPartRepositoryTests : MemoryOnlyBackendProviderRestoredForEachTestTestBase
271+
{
272+
/// <summary>
273+
/// Test InstancesWithChartCellColumn
274+
/// </summary>
275+
[Test]
276+
public void InstancesWithChartCellColumn()
277+
{
278+
var repo = (ConstituentChartCellPartRepository)Cache.ServiceLocator.GetInstance<IConstituentChartCellPartRepository>();
279+
ICmPossibility template = Cache.LangProject.GetDefaultChartTemplate();
280+
IDsConstChart chart = SetupChart(template); // This DOES add the chart as a reference to the template.
281+
282+
IEnumerable<IConstituentChartCellPart> chartCells = repo.InstancesWithChartCellColumn(template);
283+
Assert.AreEqual(1, template.ReferringObjects.Count(), "The chart should be included as a referring object");
284+
Assert.AreEqual(0, chartCells.Count(), "The chart should not be included as a chart cell");
285+
}
286+
287+
private IDsConstChart SetupChart(ICmPossibility template)
288+
{
289+
var servLoc = Cache.ServiceLocator;
290+
var text = servLoc.GetInstance<ITextFactory>().Create();
291+
var stText = servLoc.GetInstance<IStTextFactory>().Create();
292+
text.ContentsOA = stText;
293+
return servLoc.GetInstance<IDsConstChartFactory>().Create(Cache.LangProject.DiscourseDataOA, stText, template);
294+
}
295+
}
296+
#endregion
263297

264298
#region PunctuationFormRepository Tests
265299
/// ----------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)