public void TestRawJsonInvalidFormat() { // Arrange Mock <ILoggingAdapter <JsonParsingManager> > mockLogger = new Mock <ILoggingAdapter <JsonParsingManager> >(); mockLogger.Setup(logger => logger.LogError(It.IsAny <Exception>(), It.IsAny <string>())).Verifiable(); JsonParsingManager manager = new JsonParsingManager(mockLogger.Object); // Act manager.ParseRawJsonFile("I am not a JSON string"); // Assert Assert.Fail(); }
public void TestRawJsonValidFormat() { // Arrange Mock <ILoggingAdapter <JsonParsingManager> > mockLogger = new Mock <ILoggingAdapter <JsonParsingManager> >(); mockLogger.Setup(logger => logger.LogError(It.IsAny <Exception>(), It.IsAny <string>())).Verifiable(); JsonParsingManager manager = new JsonParsingManager(mockLogger.Object); // Act const string validJsonData = @"{ ""card_set"":{ ""version"":1,""set_info"":{ ""set_id"":0,""pack_item_def"":0,""name"":{ ""english"":""Base Set""} },""card_list"":[{""card_id"":1000,""base_card_id"":1000,""card_type"":""Stronghold"",""card_name"":{""english"":""Ancient Tower""},""card_text"":{},""mini_image"":{""default"":""https://steamcdn-a.akamaihd.net/apps/583950/icons/set00/1000.91b2ed80da07ef5cf343540b09687fbf875168c8.png""},""large_image"":{""default"":""https://steamcdn-a.akamaihd.net/apps/583950/icons/set00/1000_large_english.3dea67025da70c778d014dc3aae80c0c0a7008a6.png""},""ingame_image"":{},""hit_points"":80,""references"":[]}]}}"; CardSet set = manager.ParseRawJsonFile(validJsonData); // Assert Assert.IsNotNull(set); Assert.IsNotNull(set.card_list); Assert.IsTrue(set.card_list.Count > 0); }