예제 #1
0
        public async Task <int> RemoveAliasAsync(int id)
        {
            var alias = _context.GetAliases().SingleOrDefault(c => c.ID == id);

            if (alias != null)
            {
                _context.DeleteAlias(alias);
            }
            return(await _context.SaveChangesAsync());
        }
        public void DeleteAlias_calls_EfCore_Remove()
        {
            // Arrange
            var mockAliasSet = new Mock <DbSet <Alias> >();

            _mockContext.SetupGet(m => m.Aliases).Returns(mockAliasSet.Object);
            var testAlias = new Alias();

            // Act
            _testRepo.DeleteAlias(testAlias);

            // Assert
            mockAliasSet.Verify(m => m.Remove(testAlias), Times.Once());
        }