public void GivenNoCacheFileExists_WhenAttemptingToReadACacheFrom_ThenANullObject_ShouldBeReturned() { if (System.IO.File.Exists(GitHubVersionResponse.CacheFileName)) { GitHubVersionResponse.ClearCache(); } var cache = GitHubVersionResponse.TryReadFromCache(); Assert.Null(cache); }
public void GivenAGitHubVersionResponse_WhenCachingTheResponse_ThenACacheFile_ShouldBeSaved() { var responseToCache = new GitHubVersionResponse() { Name = "test", ResponseDate = DateTime.Now, Tag = "tag", Url = "url", When = new DateTimeOffset(DateTime.Now) }; responseToCache.SaveCache(); var cache = GitHubVersionResponse.TryReadFromCache(); var cacheIsEqual = (cache != null && cache.Name == responseToCache.Name && cache.ResponseDate == responseToCache.ResponseDate && cache.Tag == responseToCache.Tag && cache.Url == responseToCache.Url && cache.When == responseToCache.When); Assert.True(cacheIsEqual); GitHubVersionResponse.ClearCache(); }