Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ILogger     logger     = new Logger();
            IDownloader downloader = new Downloader(logger);
            IRepository <FeatureCollection> repository = new XMLRepository <FeatureCollection>(logger);

            var data             = downloader.DownloadInfo("https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&limit=20");
            var deserializedData = JsonConvert.DeserializeObject <FeatureCollection>(data);

            repository.Add(deserializedData);
        }
 public void ShouldAddANewProduct()
 {
     var xmlString = "<ArrayOfProduct></ArrayOfProduct>";
     var repository = new XMLRepository<Product,int>(xmlString, "ArrayOfProduct");
     repository.Add(new Product
     {
         Category = "Food",
         Name = "Bread",
         Price = 10,
         Stock = 4
     });
 }
 public void ShouldGetAllProduct()
 {
     var xmlString = "<ArrayOfProduct></ArrayOfProduct>";
     var repository = new XMLRepository<Product, int>(xmlString, "ArrayOfProduct");
     repository.Add(new Product
     {
         Category = "Food",
         Name = "Bread",
         Price = 10,
         Stock = 4
     });
     var actualResult = repository.GetAll();
     Assert.AreEqual(3, actualResult.Count());
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ILogger     logger     = new FileLogger();
            IDownloader downloader = new Downloader(logger);
            IRepository <FeatureCollection> repository = new XMLRepository <FeatureCollection>(logger);

            var data = downloader.Download("https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&limit=50");

            if (!string.IsNullOrEmpty(data))
            {
                var deserializedData = JsonConvert.DeserializeObject <FeatureCollection>(data);
                repository.Add(deserializedData);
            }
            else
            {
                System.Console.WriteLine("Произошла ошибка, обратитесь к системному администратору");
                System.Console.ReadLine();
            }
        }