Пример #1
0
        /// <summary>
        /// Load book stock from a json string
        /// </summary>
        /// <param name="catallogAsJson">Book stock in json format</param>
        public void Import(string catallogAsJson)
        {
            if (!string.IsNullOrWhiteSpace(CatalogSchema))
            {
                BookStock.ValidateJsonFormat(catallogAsJson, CatalogSchema);
            }

            bookStock  = BookStock.FromJson(catallogAsJson);
            Books      = bookStock.Books.ToDictionary(b => b.Name, b => b);
            Categories = bookStock.Categories.ToDictionary(c => c.Name, c => c.Discount);
        }
Пример #2
0
 public void Should_Throw_Exception_If_Json_Format_Invalid() =>
 Assert.ThrowsException <InvalidJsonFormatException>(() => BookStock.ValidateJsonFormat(InvalidCatalog, catalogSchema));