diff --git a/vCardEditor_Test/JsonEntries.cs b/vCardEditor_Test/JsonEntries.cs index 059d8df..868f42a 100644 --- a/vCardEditor_Test/JsonEntries.cs +++ b/vCardEditor_Test/JsonEntries.cs @@ -44,5 +44,26 @@ } } - } + + public static string InvalidJsonValid + { + get + { + return @"{ + ""version"": ""1.0"", + ""languages"": { + ""en"": { + ""name"": ""English"", + ""messages"": { + ""MSG_001"": ""Save current file before?"", + ""MSG_002"": ""File"" + _002"": ""Fichier"" + } + } + } + }"; + + } + } + } } diff --git a/vCardEditor_Test/LocalizationLoaderTest.cs b/vCardEditor_Test/LocalizationLoaderTest.cs index 39ff84f..353e9fe 100644 --- a/vCardEditor_Test/LocalizationLoaderTest.cs +++ b/vCardEditor_Test/LocalizationLoaderTest.cs @@ -1,6 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; -using System; using vCardEditor.Libs.TinyJson; using vCardEditor.Repository; @@ -22,5 +21,18 @@ namespace vCardEditor_Test Assert.IsTrue(embeddedlang.languages.Count == 2, "Number of json entries invalid"); } + + [TestMethod] + public void IncorrectJsonLoaded_Test() + { + var fileHandler = Substitute.For(); + fileHandler.LoadJsonFromAssembly(Arg.Any()).Returns(JsonEntries.InvalidJsonValid); + var JsonParser = new TinyJsonParser(); + + var embeddedlang = new LocalizationLoader(JsonParser, fileHandler).LoadEmbedded(); + + + Assert.IsTrue(embeddedlang.version == "1.0", "Json version incorrect"); + } } } diff --git a/vCardEditor_Test/MainPresenterTest.cs b/vCardEditor_Test/MainPresenterTest.cs index 2f86b57..e7ec3c0 100644 --- a/vCardEditor_Test/MainPresenterTest.cs +++ b/vCardEditor_Test/MainPresenterTest.cs @@ -73,7 +73,7 @@ namespace vCardEditor_Test view.NewFileOpened += Raise.EventWith(new EventArg("filename.vcf")); repo.Contacts[1].isDirty = true; - + fileHandler.FileExist(Arg.Any()).Returns(false); view.NewFileOpened += Raise.EventWith(new EventArg("filename2.vcf")); view.Received().AskMessage(Arg.Any(), Arg.Any());