public void GetSnapshot() { var mock = new Mock <IHttpClient>(); mock.Setup(x => x.JsonGet(It.IsAny <string>())) .ReturnsAsync(@"{""title"":""Salt for all""}"); var importer = new SnapshotImporter(mock.Object, _data.Object, _log.Object); var result = importer.GetSnapshot(new Tuple <string, string>("standard", "2016-09-10")).Result; Assert.That(result.Title, Is.EqualTo("Salt for all")); }
public void GetSnapshot_Error() { var mock = new Mock <IHttpClient>(); mock.Setup(x => x.JsonGet(It.IsAny <string>())) .ReturnsAsync(@"{""error"":{""status"":500}}"); var importer = new SnapshotImporter(mock.Object, _data.Object, _log.Object); Assert.That(async() => await importer.GetSnapshot(new Tuple <string, string>("standard", "2016-09-10")), Throws.TypeOf <ImportException>() .With.Message.EqualTo("Getting the snapshot failed (500)")); }
public void GetSnapshotTest() { //var mock = new Mock<IHttpClient>(); //mock.Setup(x => x.JsonGet(It.IsAny<string>())).ReturnsAsync(@"{""title"":""Salt for all""}"); var httpClient = new HttpClient(); var trackerRepository = new TrackerRepository(); var importer = new SnapshotImporter(httpClient, trackerRepository); var result = importer.GetSnapshot(new Tuple <string, string>("standard", "2016-09-10")).Result; Assert.AreEqual("Salt for all", result.Title); }