Beispiel #1
0
        public async Task <int> UpdateAliasAsync(int id, string name, int payeeId)
        {
            Alias originalAlias = _context.GetAliases()
                                  .FirstOrDefault(a => a.ID == id) ?? throw new IdNotFoundException($"No Alias found for Id = {id}");

            originalAlias.Name    = name;
            originalAlias.PayeeID = payeeId;
            ValidateAlias(originalAlias);

            try {
                _context.EditAlias(originalAlias);
                return(await _context.SaveChangesAsync());
            } catch (DbUpdateConcurrencyException) {
                throw new ConcurrencyException();
            }
        }
        public void EditAlias_calls_EFCore_Update()
        {
            // Arrange
            var mockAliasSet = new Mock <DbSet <Alias> >();

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

            // Act
            _testRepo.EditAlias(testAlias);

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