Ejemplo n.º 1
0
        public void Should_DeleteById()
        {
            // Arrange
            var entities   = FakeEntity.FakeEntities();
            var entity     = entities.First();
            var repository = new CacheRepository <FakeEntity>(entities);

            // Act
            repository.Delete(UserId, entity.Id);

            // Assert
            Assert.IsFalse(repository.Exists(entity.Id));
        }
Ejemplo n.º 2
0
        public void Should_DeleteByQuery()
        {
            // Arrange
            var entities = FakeEntity.FakeEntities();
            IRepository <FakeEntity> repository = new CacheRepository <FakeEntity>(entities);
            var query = repository.Query().IsNotDeleted();

            // Act
            repository.Delete(UserId, query);

            // Assert
            foreach (var entity in entities)
            {
                Assert.IsFalse(repository.Exists(entity.Id));
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            IRepository <Customer> cacheRepository = new CacheRepository <Customer>();

            bool tryAgain = true;

            do
            {
                // Add record to cache
                Console.WriteLine("Adding record to cache");
                Customer customer = new Customer()
                {
                    FirstName = "Donald", LastName = "Trump"
                };
                cacheRepository.Create(customer);

                // Get cache items
                Console.WriteLine("Retrieving records from cache");
                IEnumerable <Customer> customers = cacheRepository.Get();
                Console.WriteLine(string.Format("Amount of items in cache: {0}", customers.Count()));

                // Remove from cache
                Console.WriteLine("Removing record from cache");
                cacheRepository.Delete(customer);
                Console.WriteLine(string.Format("Amount of items in cache: {0}", customers.Count()));

                Console.WriteLine("Re-run? (Y/N)");
                if (Console.ReadLine() != "Y")
                {
                    tryAgain = false;
                }
            }while (tryAgain);


            Console.WriteLine("Press <Enter> to stop the client.");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
 public void DeleteAdmin(int id)
 {
     AdminRepository.Delete(id);
     CacheRepository.Delete($"{AdminCache}-{id}");
     UnitOfWork.Save();
 }
Ejemplo n.º 5
0
 public void DeleteFile(int id)
 {
     FileRepository.Delete(id);
     CacheRepository.Delete($"{FileCache}-{id}");
     UnitOfWork.Save();
 }