public async void CreateAsync_ReturnsCreatedElement()
        {
            var repositoryMock = new Mock <ICrudRepository>();

            repositoryMock.Setup(_ => _.CreateAsync <Guid, TestEntity>(It.IsAny <TestEntity>())).ReturnsAsync(_entity);
            var service = new CrudServiceBase <Guid, TestEntity>(repositoryMock.Object);

            var result = await service.CreateAsync(_entity);

            Assert.Equal(_entity.Id, result.Id);
            repositoryMock.Verify(_ => _.CreateAsync <Guid, TestEntity>(It.IsAny <TestEntity>()), Times.Once);
            repositoryMock.Verify(_ => _.SaveChangesAsync(), Times.Once);
        }
Пример #2
0
 public async Task <T2> CreateAsync(T2 entity) => await _service.CreateAsync(entity);