Skip to content

Commit

Permalink
[#227] [edit] StringTable dynamic items convert to IDictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
i4004 committed Jan 28, 2024
1 parent a8712a5 commit d5c877e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Simplify.Web.Tests/Modules/Data/StringTableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Constructor_StringTableFound_ItemsLoadedCorrectly()
_stringTable.Setup();

// Assert
Assert.AreEqual("Your site title!", _stringTable.Items.SiteTitle);
Assert.That(_stringTable.Items["SiteTitle"], Is.EqualTo("Your site title!"));
}

[Test]
Expand Down Expand Up @@ -94,7 +94,7 @@ public void Constructor_StringTableNotFound_DefaultLoaded()
_stringTable.Setup();

// Assert
Assert.AreEqual("Your site title!", _stringTable.Items.SiteTitle);
Assert.That(_stringTable.Items["SiteTitle"], Is.EqualTo("Your site title!"));
}

[Test]
Expand All @@ -112,8 +112,8 @@ public void Constructor_StringTableWithMissingItems_MissingItemsLoadedFromDefaul

// Assert

Assert.AreEqual("Foo", _stringTable.Items.Item1);
Assert.AreEqual("BarDef", _stringTable.Items.Item2);
Assert.That(_stringTable.Items["Item1"], Is.EqualTo("Foo"));
Assert.That(_stringTable.Items["Item2"], Is.EqualTo("BarDef"));
}

[Test]
Expand Down Expand Up @@ -179,6 +179,6 @@ public void Constructor_CacheEnabled_LoadedFromCacheSecondTime()
// Assert

_fileReader.Verify(x => x.LoadXDocument(It.IsAny<string>(), It.IsAny<bool>()), Times.Once);
Assert.AreEqual("Your site title!", _stringTable.Items.SiteTitle);
Assert.That(_stringTable.Items["SiteTitle"], Is.EqualTo("Your site title!"));
}
}
6 changes: 4 additions & 2 deletions src/Simplify.Web/Modules/Data/IStringTable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Simplify.Web.Modules.Data;
using System.Collections.Generic;

namespace Simplify.Web.Modules.Data;

/// <summary>
/// Represent string table.
Expand All @@ -8,7 +10,7 @@ public interface IStringTable
/// <summary>
/// String table items.
/// </summary>
dynamic Items { get; }
IDictionary<string, object?> Items { get; }

/// <summary>
/// Setups this string table.
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/Modules/Data/StringTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public sealed class StringTable(IList<string> stringTableFiles,
/// <summary>
/// String table items
/// </summary>
public dynamic Items { get; private set; } = null!;
public IDictionary<string, object?> Items { get; private set; } = null!;

/// <summary>
/// Setups this string table.
Expand Down

0 comments on commit d5c877e

Please sign in to comment.