本文整理汇总了C#中StringTable.Setup方法的典型用法代码示例。如果您正苦于以下问题:C# StringTable.Setup方法的具体用法?C# StringTable.Setup怎么用?C# StringTable.Setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable.Setup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor_NoStringTable_NoItemsLoaded
public void Constructor_NoStringTable_NoItemsLoaded()
{
// Act
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
_stringTable.Setup();
// Assert
Assert.AreEqual(0, ((IDictionary<string, object>)_stringTable.Items).Count);
}
示例2: Constructor_StringTableFound_ItemsLoadedCorrectly
public void Constructor_StringTableFound_ItemsLoadedCorrectly()
{
// Assign
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"SiteTitle\" value=\"Your site title!\" /></items>"));
// Act
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
_stringTable.Setup();
// Assert
Assert.AreEqual("Your site title!", _stringTable.Items.SiteTitle);
}
示例3: Constructor_CurrentLanguageEqualToDefaultLanguage_DefaultItemsNotLoaded
public void Constructor_CurrentLanguageEqualToDefaultLanguage_DefaultItemsNotLoaded()
{
// Assign
_languageManager.SetupGet(x => x.Language).Returns("en");
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"SiteTitle\" value=\"Your site title!\" /></items>"));
// Act
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
_stringTable.Setup();
// Assert
_fileReader.Verify(x => x.LoadXDocument(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
}
示例4: GetItem_ItemNotFound_Null
public void GetItem_ItemNotFound_Null()
{
// Assign
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"FooEnum.FooItem1\" value=\"Foo\" /></items>"));
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
// Act
_stringTable.Setup();
// Act & Assert
Assert.IsNull(_stringTable.GetItem("Foo"));
}
示例5: GetAssociatedValue_EnumItems_GetCorrectly
public void GetAssociatedValue_EnumItems_GetCorrectly()
{
// Assign
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"FooEnum.FooItem1\" value=\"Foo\" /></items>"));
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
// Act
_stringTable.Setup();
// Act & Assert
Assert.AreEqual("Foo", _stringTable.GetAssociatedValue(FooEnum.FooItem1));
Assert.IsNull(_stringTable.GetAssociatedValue(FooEnum.FooItem2));
}
示例6: Constructor_StringTableWithMissingItems_MissingItemsLoadedFromDefaultStringTable
public void Constructor_StringTableWithMissingItems_MissingItemsLoadedFromDefaultStringTable()
{
// Assign
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"Item1\" value=\"Foo\" /></items>"));
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>(), It.Is<string>(d => d == DefaultLanguage))).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"Item1\" value=\"FooDef\" /><item name=\"Item2\" value=\"BarDef\" /></items>"));
// Act
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object);
_stringTable.Setup();
// Assert
Assert.AreEqual("Foo", _stringTable.Items.Item1);
Assert.AreEqual("BarDef", _stringTable.Items.Item2);
}
示例7: Constructor_CacheEnabled_LoadedFromCacheSecondTime
public void Constructor_CacheEnabled_LoadedFromCacheSecondTime()
{
// Assign
_fileReader.Setup(x => x.LoadXDocument(It.IsAny<string>(), It.IsAny<bool>())).Returns(XDocument.Parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><items><item name=\"SiteTitle\" value=\"Your site title!\" /></items>"));
// Act
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object, true);
_stringTable.Setup();
_stringTable = new StringTable(_stringTableFiles, DefaultLanguage, _languageManagerProvider.Object, _fileReader.Object, true);
_stringTable.Setup();
// Assert
_fileReader.Verify(x => x.LoadXDocument(It.IsAny<string>(), It.IsAny<bool>()), Times.Once);
Assert.AreEqual("Your site title!", _stringTable.Items.SiteTitle);
}