public async Task AddRange_ShouldAddMultipleRecipients()
        {
            // Arrange
            IEnumerable <MessageRecipient> messageRecipients = new[]
            {
                new MessageRecipient(),
                new MessageRecipient(),
            };

            _contextMock.Setup(m => m.MessageRecipients.AddRangeAsync(messageRecipients, It.IsAny <CancellationToken>()));

            MessageRecipientRepository repository = new MessageRecipientRepository(_contextMock.Object);

            // Act
            await repository.AddRange(messageRecipients);

            // Assert
            _contextMock.Verify(m => m.MessageRecipients.AddRangeAsync(messageRecipients, It.IsAny <CancellationToken>()));
        }
Exemplo n.º 2
0
    public async Task AddRange_ShouldAddMultipleRecipients()
    {
        // Arrange
        IEnumerable <MessageRecipient> messageRecipients = new[]
        {
            new MessageRecipient(),
            new MessageRecipient(),
        };

        IMessageRecipientRepository repository = new MessageRecipientRepository(_context);

        // Act
        await repository.AddRange(messageRecipients);

        await _context.SaveChangesAsync();

        _context.ChangeTracker.Clear();

        // Assert
        Assert.All(messageRecipients, mr => Assert.NotEqual(0, mr.MessageRecipientId));
    }