diff --git a/Glyssen/Dialogs/AssignCharacterDlg.cs b/Glyssen/Dialogs/AssignCharacterDlg.cs
index 57d7ddac7..d2f118c8c 100644
--- a/Glyssen/Dialogs/AssignCharacterDlg.cs
+++ b/Glyssen/Dialogs/AssignCharacterDlg.cs
@@ -524,9 +524,7 @@ private void SetReferenceTextForeColor(DataGridViewRow row, AssignCharacterViewM
private void SetDeliveryCellValue(DataGridViewRow row, Block correlatedBlock)
{
- var delivery = correlatedBlock.Delivery;
- if (IsNullOrEmpty(delivery))
- delivery = correlatedBlock.ReferenceBlocks.Single().Delivery;
+ var delivery = m_viewModel.GetEffectiveDelivery(correlatedBlock);
if (IsNullOrEmpty(delivery))
delivery = ((AssignCharacterViewModel.Delivery)colDelivery.Items[0]).LocalizedDisplay;
row.Cells[colDelivery.Index].Value = delivery;
diff --git a/Glyssen/Glyssen.csproj b/Glyssen/Glyssen.csproj
index 5208a15db..8cc649e57 100644
--- a/Glyssen/Glyssen.csproj
+++ b/Glyssen/Glyssen.csproj
@@ -67,6 +67,7 @@
1
..\output\Debug\
false
+ DEBUG
..\output\Release\
diff --git a/GlyssenEngine/Project.cs b/GlyssenEngine/Project.cs
index 8a94a1c45..933bfb827 100644
--- a/GlyssenEngine/Project.cs
+++ b/GlyssenEngine/Project.cs
@@ -615,6 +615,8 @@ public bool RemoveProjectCharacterDetail(string character)
public bool AddNewReportingClauses(IEnumerable reportingClauses)
{
var retVal = false;
+ if (m_metadata.Language.ReportingClauses == null)
+ m_metadata.Language.ReportingClauses = new HashSet();
foreach (var reportingClause in reportingClauses)
retVal |= m_metadata.Language.ReportingClauses.Add(reportingClause);
return retVal;
diff --git a/GlyssenEngine/ViewModels/AssignCharacterViewModel.cs b/GlyssenEngine/ViewModels/AssignCharacterViewModel.cs
index 56f9789b9..cbfebf74e 100644
--- a/GlyssenEngine/ViewModels/AssignCharacterViewModel.cs
+++ b/GlyssenEngine/ViewModels/AssignCharacterViewModel.cs
@@ -10,6 +10,7 @@
using CollectionExtensions = SIL.Extensions.CollectionExtensions;
using SIL;
using SIL.Reporting;
+using static System.String;
namespace GlyssenEngine.ViewModels
{
@@ -148,7 +149,7 @@ private void AddPendingProjectCharacterVerseDataIfNeeded(Block block, string cha
private void AddPendingProjectCharacterVerseData(Block block, string characterId, Delivery delivery = null)
{
- Debug.Assert(!String.IsNullOrEmpty(characterId));
+ Debug.Assert(!IsNullOrEmpty(characterId));
m_pendingCharacterDeliveryAdditions.Add(new CharacterSpeakingMode(
characterId,
delivery == null ? Delivery.Normal.Text : delivery.Text,
@@ -313,7 +314,7 @@ public IEnumerable GetUniqueCharacters(string filterText = null)
{
var charactersForCurrentRef = GetUniqueCharacterVerseObjectsForCurrentReference();
- if (string.IsNullOrWhiteSpace(filterText))
+ if (IsNullOrWhiteSpace(filterText))
{
m_currentCharacters = new HashSet(m_combinedCharacterVerseData.GetUniqueCharacterDeliveryInfo(CurrentBookId));
}
@@ -353,7 +354,7 @@ public IEnumerable GetDeliveriesForCharacter(Character selectedCharact
if (!selectedCharacter.IsNarrator)
{
foreach (var cv in m_currentCharacters.Where(c => c.Character == selectedCharacter.CharacterId &&
- !string.IsNullOrEmpty(c.Delivery) &&
+ !IsNullOrEmpty(c.Delivery) &&
m_currentDeliveries.All(d => d.Text != c.Delivery)))
{
m_currentDeliveries.Add(new Delivery(cv.Delivery, cv.ProjectSpecific));
@@ -365,7 +366,7 @@ public IEnumerable GetDeliveriesForCharacter(Character selectedCharact
public IEnumerable GetUniqueDeliveries(string filterText = null)
{
List deliveries;
- if (string.IsNullOrWhiteSpace(filterText))
+ if (IsNullOrWhiteSpace(filterText))
deliveries = m_combinedCharacterVerseData.GetUniqueDeliveries()
.Select(d => m_currentDeliveries.FirstOrDefault(cd => cd.Text == d) ?? new Delivery(d)).ToList();
else
@@ -386,14 +387,16 @@ public IEnumerable GetDeliveriesForCurrentReferenceTextMatchup()
foreach (var block in CurrentReferenceTextMatchup.CorrelatedBlocks)
{
- foreach (var delivery in GetUniqueCharacterVerseObjectsForBlock(block).Where(cv => !String.IsNullOrEmpty(cv.Delivery))
+ foreach (var delivery in GetUniqueCharacterVerseObjectsForBlock(block).Where(cv => !IsNullOrEmpty(cv.Delivery))
.Select(cv => new Delivery(cv.Delivery, cv.ProjectSpecific)))
{
if (!m_currentDeliveries.Any(d => d.Text == delivery.Text))
m_currentDeliveries.Add(delivery);
}
- if (!String.IsNullOrEmpty(block.Delivery) && !m_currentDeliveries.Any(d => d.Text == block.Delivery))
- m_currentDeliveries.Add(new Delivery(block.Delivery));
+
+ var deliveryFromBlock = GetEffectiveDelivery(block);
+ if (!IsNullOrEmpty(deliveryFromBlock) && !m_currentDeliveries.Any(d => d.Text == deliveryFromBlock))
+ m_currentDeliveries.Add(new Delivery(deliveryFromBlock));
}
m_currentDeliveries.Sort(m_deliveryComparer);
@@ -402,6 +405,19 @@ public IEnumerable GetDeliveriesForCurrentReferenceTextMatchup()
return m_currentDeliveries;
}
+
+ public string GetEffectiveDelivery(Block block)
+ {
+ var delivery = block.Delivery;
+ if (IsNullOrEmpty(delivery) && block.MatchesReferenceText)
+ {
+ var refBlock = block.ReferenceBlocks.Single();
+ delivery = refBlock.Delivery ??
+ (m_project.ReferenceText.HasSecondaryReferenceText ? refBlock.ReferenceBlocks.SingleOrDefault()?.Delivery : null);
+ }
+
+ return delivery;
+ }
public IEnumerable GetDeliveriesForCharacterInCurrentReferenceTextMatchup(Character character)
{
@@ -430,7 +446,7 @@ public bool IsModified(Character newCharacter, Delivery newDelivery)
return true;
if (newDelivery.IsNormal)
- return (!string.IsNullOrEmpty(currentBlock.Delivery));
+ return (!IsNullOrEmpty(currentBlock.Delivery));
return newDelivery.Text != currentBlock.Delivery;
}
@@ -581,7 +597,7 @@ private string GetCurrentRelevantAlias(string characterId)
{
if (character.CharacterId == characterId)
{
- if (!string.IsNullOrEmpty(character.LocalizedAlias))
+ if (!IsNullOrEmpty(character.LocalizedAlias))
return character.LocalizedAlias;
break;
}
@@ -602,7 +618,7 @@ public void SplitBlock(IEnumerable blockSplits, List c.Key == 0).Value;
if (currentBlock.CharacterId != firstCharacterId)
{
- if (string.IsNullOrEmpty(firstCharacterId))
+ if (IsNullOrEmpty(firstCharacterId))
currentBlock.CharacterId = CharacterVerseData.kUnexpectedCharacter;
else
{
@@ -625,7 +641,7 @@ public void SplitBlock(IEnumerable blockSplits, List
{
int IComparer.Compare(Character x, Character y)
{
- var xTextToCompare = string.IsNullOrEmpty(x.Alias) ? x.CharacterId : x.Alias;
- var yTextToCompare = string.IsNullOrEmpty(y.Alias) ? y.CharacterId : y.Alias;
+ var xTextToCompare = IsNullOrEmpty(x.Alias) ? x.CharacterId : x.Alias;
+ var yTextToCompare = IsNullOrEmpty(y.Alias) ? y.CharacterId : y.Alias;
var result = CompareSpecialCases(x, y, xTextToCompare, yTextToCompare);
- return result != 0 ? result : string.Compare(x.CharacterId, y.CharacterId, StringComparison.InvariantCultureIgnoreCase);
+ return result != 0 ? result : Compare(x.CharacterId, y.CharacterId, StringComparison.InvariantCultureIgnoreCase);
}
}
#endregion
@@ -907,7 +923,7 @@ public class DeliveryComparer : IComparer
{
int IComparer.Compare(Delivery x, Delivery y)
{
- return String.Compare(x.Text, y.Text, StringComparison.InvariantCultureIgnoreCase);
+ return Compare(x.Text, y.Text, StringComparison.InvariantCultureIgnoreCase);
}
}
#endregion
diff --git a/GlyssenEngineTests/ViewModelTests/AssignCharacterViewModelTests.cs b/GlyssenEngineTests/ViewModelTests/AssignCharacterViewModelTests.cs
index 5117c0781..6b557a5f5 100644
--- a/GlyssenEngineTests/ViewModelTests/AssignCharacterViewModelTests.cs
+++ b/GlyssenEngineTests/ViewModelTests/AssignCharacterViewModelTests.cs
@@ -174,6 +174,7 @@ public void GetDeliveriesForCurrentReferenceTextMatchup_CannedDeliveries_GetsNor
[Test]
public void GetDeliveriesForCurrentReferenceTextMatchup_BlockSetToProjectSpecificDelivery_ResultIncludesProjectSpecificDelivery()
{
+ m_fullProjectRefreshRequired = true;
FindRefInMark(10, 49);
m_model.SetCharacterAndDelivery(m_model.GetUniqueCharactersForCurrentReference().First(c => c.CharacterId == "Jesus"),
new AssignCharacterViewModel.Delivery("ordering"));
@@ -186,6 +187,47 @@ public void GetDeliveriesForCurrentReferenceTextMatchup_BlockSetToProjectSpecifi
Assert.AreEqual(1, result.Count(d => d.Text == "ordering"));
}
+
+ #region PG-1401
+ [Test]
+ public void GetDeliveriesForCurrentReferenceTextMatchup_BlockReferenceTextSetToNonstandardDelivery_ResultIncludesNonstandardDelivery()
+ {
+ FindRefInMark(10, 49);
+ m_model.SetMode(m_model.Mode, true);
+ var baseList = m_model.GetDeliveriesForCurrentReferenceTextMatchup().ToList();
+ var block = m_model.CurrentReferenceTextMatchup.CorrelatedBlocks.First(b => b.MatchesReferenceText &&
+ b.CharacterId != CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator));
+ block.ReferenceBlocks.Single().Delivery = "slurred";
+
+ var result = m_model.GetDeliveriesForCurrentReferenceTextMatchup().ToList();
+ Assert.AreEqual(baseList.Count + 1, result.Count);
+ Assert.IsTrue(result[0].IsNormal);
+ Assert.IsTrue(baseList.All(d => result.Contains(d)));
+ Assert.IsTrue(result.Any(d => d.Text == "slurred"));
+ }
+
+ [Test]
+ public void GetDeliveriesForCurrentReferenceTextMatchup_SecondLevelBlockReferenceTextSetToNonstandardDelivery_ResultIncludesNonstandardDelivery()
+ {
+ m_fullProjectRefreshRequired = true;
+ m_testProject.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.Russian);
+ FindRefInMark(10, 49);
+ m_model.SetMode(m_model.Mode, true);
+ var baseList = m_model.GetDeliveriesForCurrentReferenceTextMatchup().ToList();
+ var block = m_model.CurrentReferenceTextMatchup.CorrelatedBlocks.First(b => b.MatchesReferenceText &&
+ b.CharacterId != CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator));
+ var refBlock = block.ReferenceBlocks.Single();
+ refBlock.Delivery = null;
+ refBlock.ReferenceBlocks.Single().Delivery = "squealing";
+
+ var result = m_model.GetDeliveriesForCurrentReferenceTextMatchup().ToList();
+ Assert.AreEqual(baseList.Count + 1, result.Count);
+ Assert.IsTrue(result[0].IsNormal);
+ Assert.IsTrue(baseList.All(d => result.Contains(d)));
+ Assert.IsTrue(result.Any(d => d.Text == "squealing"));
+ }
+ #endregion
+
[Test]
public void GetUniqueCharacters_AmbiguousQuoteNoFilter_GetsAllCharactersInMark()
{