Пример #1
0
        private void CheckCanDeleteProduct()
        {
            var product = new OsyProduct() { Name = "Coke", Category = "Drinks" };
            IProductRepository repository = new ProductRepository();
            repository.Add(product);

            Guid oldId = product.Id;

            Console.WriteLine(string.Format("Removing product with id: {0}", oldId));
            repository.Remove(product);

            OsyProduct result = repository.GetById(oldId);
            Console.WriteLine(result != null ? string.Format("product with id {0} is in DB", oldId) :
                string.Format("product with id {0} is not in DB", oldId));
        }
Пример #2
0
        private void AddProduct()
        {
            var product = new OsyProduct { Name = "Apple", Category = "Fruit" };
            IProductRepository repository = new ProductRepository();
            repository.Add(product);

            OsyProduct fromDb = repository.GetById(product.Id);
            if (product.Id == fromDb.Id &&
                product.Name == fromDb.Name &&
                product.Category == fromDb.Category &&
                product.Discontinued == fromDb.Discontinued)
            {
                Console.WriteLine("Equal");
            }
            else
            {
                Console.WriteLine("Not equal");
            }
            Console.WriteLine(Object.ReferenceEquals(product, fromDb) ? "references equal" : "references not equal");
        }