public void TestFileLocationEmpty() { // 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.ParseRawJsonFileLocation(""); // Assert }
public void TestFileLocationInvalidJsonKeys() { // 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 validJsonDataWithWrongKeys = @"{ ""key_A"":""https:\/\/steamcdn-a.akamaihd.net\/"",""key_B"":""\/apps\/583950\/resource\/card_set_0.BB8732855C64ACE2696DCF5E25DEDD98D134DD2A.json"",""key_C"":1541860748}"; CardSetFile cardSetFile = manager.ParseRawJsonFileLocation(validJsonDataWithWrongKeys); // Assert }
public void TestFileLocationValidFormatUtcDate() { // Arrange double unixTimeStamp = 1541860748; const string validJsonData = @"{ ""cdn_root"":""https:\/\/steamcdn-a.akamaihd.net\/"",""url"":""\/apps\/583950\/resource\/card_set_0.BB8732855C64ACE2696DCF5E25DEDD98D134DD2A.json"",""expire_time"":1541860748}"; 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 CardSetFile cardSetFile = manager.ParseRawJsonFileLocation(validJsonData); // Assert Assert.AreEqual(unixTimeStamp, cardSetFile.expire_time); }
public void TestFileLocationValidFormatWithAdditionalKeys() { // 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 = @"{ ""cdn_root"":""https:\/\/steamcdn-a.akamaihd.net\/"",""url"":""\/apps\/583950\/resource\/card_set_0.BB8732855C64ACE2696DCF5E25DEDD98D134DD2A.json"",""expire_time"":1541860748,""key_D"":""123""}"; CardSetFile cardSetFile = manager.ParseRawJsonFileLocation(validJsonData); // Assert Assert.IsNotNull(cardSetFile); Assert.IsNotNull(cardSetFile.cdn_root); Assert.IsNotNull(cardSetFile.expire_time); Assert.IsNotNull(cardSetFile.url); }
public void TestFileLocationDefaultFormat() { // Arrange const string escapeChars = @"\/"; 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 jsonData = "{ \"cdn_root\":\"https:\\/\\/steamcdn-a.akamaihd.net\\/\",\"url\":\"\\/apps\\/583950\\/resource\\/card_set_1.0E871AFDD63D1CBD0FB52D924DF1923C4A6D443A.json\",\"expire_time\":1541954560}"; CardSetFile cardSetFile = manager.ParseRawJsonFileLocation(jsonData); // Assert Assert.IsNotNull(cardSetFile); Assert.IsNotNull(cardSetFile.cdn_root); Assert.IsNotNull(cardSetFile.expire_time); Assert.IsNotNull(cardSetFile.url); Assert.IsFalse(cardSetFile.cdn_root.Contains(escapeChars)); Assert.IsFalse(cardSetFile.url.Contains(escapeChars)); }