public void Action() { VieDeMerdeService query = new VieDeMerdeService(); VieDeMerdeCollection vdms = query.GetLastVieDeMerdes(); vdms.Display(this.Writer); }
public void GetVDM() { // Arrange IDownloaderFactory downloaderFactory = Mock.Of <IDownloaderFactory>(); IDownloader downloader = Mock.Of <IDownloader>(); Mock.Get(downloaderFactory) .Setup(x => x.Create()) .Returns(() => downloader); Mock.Get(downloader) .Setup(x => x.DownloadString("https://www.viedemerde.fr")) .Returns(() => File.ReadAllText("viedemerde.html")); // Act VieDeMerdeService query = new VieDeMerdeService(downloaderFactory); VieDeMerdeCollection vdms = query.GetLastVieDeMerdes(); // Assert Assert.AreEqual(30, vdms.VieDemerde.Length); Assert.AreEqual("Le trottoir c'est pas pour les chiens", vdms.VieDemerde[0].Titre); Assert.AreEqual("lau", vdms.VieDemerde[0].Auteur); Assert.AreEqual("Dernier recours", vdms.VieDemerde[1].Titre); Assert.AreEqual("Anonyme", vdms.VieDemerde[1].Auteur); Assert.AreEqual("Dictature", vdms.VieDemerde[2].Titre); Assert.AreEqual("Plante verte", vdms.VieDemerde[2].Auteur); }
public void Action() { VieDeMerdeService query = new VieDeMerdeService(); VieDeMerdeCollection collection = query.GetLastVieDeMerdes(); string applicationData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string path = Path.Combine(applicationData, "FilPasRouge"); string filename = Path.Combine(path, "viedemerde.json"); this.FileSystem.CreateDirectory(path); string json = Newtonsoft.Json.JsonConvert.SerializeObject(collection); this.FileSystem.WriteAllText(filename, json); }
public void Action() { string applicationData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string path = Path.Combine(applicationData, "FilPasRouge"); string filename = Path.Combine(path, "viedemerde.json"); if (this.FileSystem.Exists(filename)) { string json = this.FileSystem.ReadAllText(filename); VieDeMerdeCollection collection = Newtonsoft.Json.JsonConvert.DeserializeObject <VieDeMerdeCollection>(json); collection.Display(this.Writer); } else { this.Writer.WriteLine("Pas de données."); } }