Skip to content

Commit

Permalink
Fixed some failing tests. Updated currency and timezone resources.
Browse files Browse the repository at this point in the history
- Setting the Active property of a ConfigurationSection now triggers the ActiveChanged event.
- Formatting a Financial now correctly uses the supplied culture if a culture was not found for the currency.
- Changed a cyptography test to not output the raw test string it uses as the characters it shows lags the UI.
One test still failing, but the fix is not simple.
  • Loading branch information
billings7 committed Oct 5, 2016
1 parent 428a014 commit 55f0c3a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Cryptography/Test/CryptographyConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Xml.Linq;
using WebApplications.Testing;
Expand Down Expand Up @@ -154,13 +155,17 @@ public void Create_Providers_And_Save()
string random = Tester.RandomString(minLength: 1);
string encrypted = provider.EncryptToString(random);
Assert.IsNotNull(encrypted);
Assert.AreNotEqual(random, encrypted);
Assert.IsFalse(random == encrypted, "Expected and actual string are equal.");

if (reloadProvider.CanDecrypt)
{
string decrypted = provider.DecryptToString(encrypted);
Assert.IsNotNull(decrypted);
Assert.AreEqual(random, decrypted);
Assert.IsTrue(
random == decrypted,
"Expected: {0}\r\n Actual: {1}",
Convert.ToBase64String(Encoding.Unicode.GetBytes(random)),
Convert.ToBase64String(Encoding.Unicode.GetBytes(decrypted)));
}
}

Expand Down
9 changes: 9 additions & 0 deletions Scheduling/Test/TestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using NodaTime;
using System;
using System.Linq;
using System.Threading;
using WebApplications.Utilities.Annotations;
using WebApplications.Utilities.Configuration;
using WebApplications.Utilities.Scheduling.Configuration;
Expand Down Expand Up @@ -92,6 +93,8 @@ public void TestConfigurationChangeNoChanges()

SchedulerConfiguration.Active = CloneConfig(current);

Thread.Sleep(ConfigurationExtensions.EventBufferMs * 2);

Assert.AreSame(oneOff, Scheduler.GetSchedule("OneOff"));
Assert.AreSame(gap, Scheduler.GetSchedule("Gap"));
Assert.AreSame(etm, Scheduler.GetSchedule("EveryTwoMonths"));
Expand Down Expand Up @@ -124,6 +127,8 @@ public void TestConfigurationChangeEnabled()

SchedulerConfiguration.Active = newConfig;

Thread.Sleep(ConfigurationExtensions.EventBufferMs * 2);

Assert.AreEqual(Scheduler.Enabled, false);

Assert.AreSame(oneOff, Scheduler.GetSchedule("OneOff"));
Expand Down Expand Up @@ -153,6 +158,8 @@ public void TestConfigurationChangeAggregate()

SchedulerConfiguration.Active = newConfig;

Thread.Sleep(ConfigurationExtensions.EventBufferMs * 2);

Assert.AreSame(oneOff, Scheduler.GetSchedule("OneOff"));
Assert.AreSame(gap, Scheduler.GetSchedule("Gap"));
Assert.AreSame(etm, Scheduler.GetSchedule("EveryTwoMonths"));
Expand Down Expand Up @@ -183,6 +190,8 @@ public void TestConfigurationChangeGap()

SchedulerConfiguration.Active = newConfig;

Thread.Sleep(ConfigurationExtensions.EventBufferMs * 2);

Assert.AreSame(oneOff, Scheduler.GetSchedule("OneOff"));
Assert.AreNotSame(gap, Scheduler.GetSchedule("Gap"));
Assert.AreSame(etm, Scheduler.GetSchedule("EveryTwoMonths"));
Expand Down
1 change: 1 addition & 0 deletions Utilities/Configuration/ConfigurationSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public static T Active
if (Equals(active, value)) return;
if (value.IsDisposed) throw new ObjectDisposedException(typeof(T).ToString());
_active = value;
_activeChangeAction.Run(value.FullPath);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Financials/Financial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ private string FormatCurrency([NotNull] CultureInfo culture)
cultures.Length > 0)
found = cultures[0];

return string.Format(found, "{0:C}", _amount);
return string.Format(found ?? culture, "{0:C}", _amount);
}

/// <summary>
Expand Down
Binary file modified Utilities/Resources/iso4217.ccy
Binary file not shown.
Binary file modified Utilities/Resources/tzdb.nzd
Binary file not shown.

0 comments on commit 55f0c3a

Please sign in to comment.