Skip to content

Commit

Permalink
Made IMDIArchivingDlgViewModelTests public.
Browse files Browse the repository at this point in the history
TEMP: Added some console.log statements to try to see what's happening with TC tests
  • Loading branch information
tombogle committed Oct 4, 2024
1 parent 29b08b2 commit 29158a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 6 additions & 2 deletions SIL.Archiving.Tests/IMDIArchivingDlgViewModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using NUnit.Framework;
Expand All @@ -15,7 +14,7 @@ namespace SIL.Archiving.Tests
[TestFixture]
[OfflineSldr]
[Category("Archiving")]
internal class IMDIArchivingDlgViewModelTests
public class IMDIArchivingDlgViewModelTests
{
private class MessageData
{
Expand Down Expand Up @@ -70,6 +69,7 @@ public void TearDown()
[Test]
public void NormalizeFilename_FileName_NormalizedFileName()
{
Console.WriteLine($"IMDI Tests TEMP: {nameof(NormalizeFilename_FileName_NormalizedFileName)}");
const string fileName = "My# \nFile %\t Name&^%.mp3";
var normalized = _model.NormalizeFilename("", fileName);
Assert.AreEqual("My+File+Name_.mp3", normalized);
Expand Down Expand Up @@ -275,6 +275,8 @@ public class IMDIArchivingDlgViewModelWithOverrideDisplayInitialSummarySetTests
[Test]
public async Task DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_DefaultBehaviorOmitted()
{
Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_DefaultBehaviorOmitted)}");

ErrorReport.IsOkToInteractWithUser = false;

bool filesToArchiveCalled = false;
Expand Down Expand Up @@ -320,6 +322,8 @@ public class IMDIArchivingDlgViewModelWithFineGrainedOverridesForDisplayInitialS
[Test]
public async Task DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides()
{
Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides)}");

ErrorReport.IsOkToInteractWithUser = false;

void SetFilesToArchive(ArchivingDlgViewModel model, CancellationToken cancellationToken)
Expand Down
8 changes: 8 additions & 0 deletions SIL.Archiving.Tests/RampArchivingDlgViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ public async Task DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_Defau

model.OverrideDisplayInitialSummary = (d, c) =>
{
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_DefaultBehaviorOmitted)} overriding initial display");
customSummaryShown++;
progress.IncrementProgress();
};
Expand All @@ -769,7 +770,9 @@ public async Task DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_Defau

try
{
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_DefaultBehaviorOmitted)} before SUT");
await model.Initialize(progress, new CancellationToken()).ConfigureAwait(false);
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverrideDisplayInitialSummaryIsSet_DefaultBehaviorOmitted)} after SUT");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -806,13 +809,16 @@ void SetFilesToArchive(ArchivingDlgViewModel model, CancellationToken cancellati

void ReportMessage(string msg, ArchivingDlgViewModel.MessageType type)
{
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides)} reporting {msg}");
messagesDisplayed.Add(new Tuple<string, ArchivingDlgViewModel.MessageType>(msg, type));
}

model.OnReportMessage += ReportMessage;

IEnumerable<Tuple<string, ArchivingDlgViewModel.MessageType>> GetMessages(IDictionary<string, Tuple<IEnumerable<string>, string>> arg)
{
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides)} getting pre-archiving messages");

yield return new Tuple<string, ArchivingDlgViewModel.MessageType>(
"First pre-archiving message", Warning);
yield return new Tuple<string, ArchivingDlgViewModel.MessageType>(
Expand All @@ -826,7 +832,9 @@ void ReportMessage(string msg, ArchivingDlgViewModel.MessageType type)
var progress = new TestProgress("RAMP");
try
{
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides)} before SUT");
await model.Initialize(progress, new CancellationToken()).ConfigureAwait(false);
Console.WriteLine($"RAMP Tests TEMP: {nameof(DisplayInitialSummary_OverridenPropertiesForDisplayInitialSummaryAreSet_MessagesReflectOverrides)} after SUT");
}
catch (Exception ex)
{
Expand Down
18 changes: 16 additions & 2 deletions SIL.Archiving/ArchivingDlgViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,21 @@ public virtual void AddFileGroup(string groupId, IEnumerable<string> files,
/// ------------------------------------------------------------------------------------
private void DisplayInitialSummary(CancellationToken cancellationToken)
{
Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} start");

if (OverrideDisplayInitialSummary != null)
{
OverrideDisplayInitialSummary(FileLists, cancellationToken);
return;
}

Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} after override");

foreach (var message in AdditionalMessages)
DisplayMessage(message.Key + "\n", message.Value);

Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} after additional");

if (GetOverriddenPreArchivingMessages != null)
{
bool firstMsg = true;
Expand All @@ -354,10 +360,16 @@ private void DisplayInitialSummary(CancellationToken cancellationToken)
else
DisplayMessage(msg.Item1, msg.Item2);
}

Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} after overridden Pre-Archiving messages");
}
else
ReportProgress(Progress.GetMessage(StringId.PreArchivingStatus), MessageType.Normal,
cancellationToken);
{
ReportProgress(Progress.GetMessage(StringId.PreArchivingStatus),
MessageType.Normal, cancellationToken);

Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} after normal Pre-Archiving message");
}

foreach (var kvp in FileLists)
{
Expand All @@ -371,6 +383,8 @@ private void DisplayInitialSummary(CancellationToken cancellationToken)
foreach (var file in kvp.Value.Item1)
DisplayMessage(Path.GetFileName(file), MessageType.Bullet);
}

Console.WriteLine($"IMDI Tests TEMP: {nameof(DisplayInitialSummary)} end");
}

protected virtual string FileGroupDisplayMessage(string groupKey)
Expand Down

0 comments on commit 29158a0

Please sign in to comment.