public void Convert_Null_ReturnsEmptyString() { //Arrange var mockLP = new Mock <ILiteralProvider>(); MoqLiteralProviderSetupHelper.Init(mockLP.Object); var converter = new ResourcesTextConverter(); string resourceKey = null; //Act var converted = converter.Convert( resourceKey, typeof(string), null, CultureInfo.InvariantCulture); var convertedAsTargetType = converted as string; //Assert Assert.IsInstanceOfType(converted, typeof(string)); Assert.AreEqual(string.Empty, convertedAsTargetType); }
public void Convert_NoLiteralProvider_ReturnsEmptyString() { //Arrange var resourceKey = "someKey"; var mockLP = new Mock <AlwaysInitializedLiteralProvider> { CallBase = true }; MoqLiteralProviderSetupHelper.Init(mockLP.Object); var converter = new ResourcesTextConverter(); //Act var converted = converter.Convert( resourceKey, typeof(string), null, CultureInfo.InvariantCulture); var convertedAsTargetType = converted as string; //Assert Assert.IsInstanceOfType(converted, typeof(string)); Assert.AreEqual(string.Empty, convertedAsTargetType); }
public void Convert_NonExistingEntry_ReturnsEmptyString() { //Arrange var resourceKey = "someKey"; var mockLP = new Mock <ResourceLiteralProvider> { CallBase = true }; mockLP.Setup(resLP => resLP.GetGuiTranslationOfCurrentCulture(resourceKey)) .Returns((string)null); MoqLiteralProviderSetupHelper.Init(mockLP.Object); var converter = new ResourcesTextConverter(); //Act var converted = converter.Convert( resourceKey, typeof(string), null, CultureInfo.InvariantCulture); var convertedAsTargetType = converted as string; //Assert Assert.IsInstanceOfType(converted, typeof(string)); Assert.AreEqual(string.Empty, convertedAsTargetType); }