Ejemplo n.º 1
0
        public async Task DeleteEntitiesAsync_ItemsBySelection_ReturnsMultipleRowsDeleted()
        {
            var repositoryProvider = new Mock <IRepositoryProvider>();
            var definitionProvider = new DataAnnotationsDefinitionProvider();

            repositoryProvider.Setup(provider => provider.EntityDefinitionProvider).Returns(definitionProvider);
            repositoryProvider.Setup(provider => provider.DeleteAsync(It.IsAny <IEntitySet>(), It.IsAny <CancellationToken>())).ReturnsAsync(5);

            int actual;

            using (var provider = repositoryProvider.Object)
            {
                var repository = new EntityRepository <SubSubEntity, SubSubRow>(provider, this.mapper);
                actual = await repository.DeleteEntitiesAsync(
                    set => set.Where(filterSet => filterSet.AreEqual(entity => entity.UniqueName, "bar")),
                    CancellationToken.None);
            }

            Assert.AreEqual(5, actual);
        }