public async Task Add_ShouldAddRecipient()
        {
            // Arrange
            MessageRecipient messageRecipient = new MessageRecipient();

            _contextMock.Setup(m => m.MessageRecipients.AddAsync(messageRecipient, It.IsAny <CancellationToken>()));

            MessageRecipientRepository repository = new MessageRecipientRepository(_contextMock.Object);

            // Act
            await repository.Add(messageRecipient);

            // Assert
            _contextMock.Verify(m => m.MessageRecipients.AddAsync(messageRecipient, It.IsAny <CancellationToken>()));
        }
Exemplo n.º 2
0
    public async Task Add_ShouldAddRecipient()
    {
        // Arrange
        MessageRecipient messageRecipient = new MessageRecipient();

        IMessageRecipientRepository repository = new MessageRecipientRepository(_context);

        // Act
        await repository.Add(messageRecipient);

        await _context.SaveChangesAsync();

        _context.ChangeTracker.Clear();

        // Assert
        Assert.NotEqual(0, messageRecipient.MessageRecipientId);
        MessageRecipient addedMessageRecipient = await _context.MessageRecipients.FindAsync(messageRecipient.MessageRecipientId);

        Assert.NotNull(addedMessageRecipient);
    }