Пример #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));
        }
Пример #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));
            }
        }
Пример #3
0
        public async void Should_Insert()
        {
            // Arrange
            var entities  = FakeEntity.FakeEntities();
            var newEntity = new FakeEntity
            {
                Id = 9
            };

            var repository = new CacheRepository <FakeEntity>(entities);

            // Act
            await repository.InsertAsync(UserId, newEntity);

            var result = repository.Exists(newEntity.Id);

            // Assert
            Assert.IsTrue(result);
        }