dont feed pipeline if no elements
This commit is contained in:
parent
b7acb4c907
commit
01337a63ec
2 changed files with 29 additions and 1 deletions
|
@ -29,7 +29,9 @@ namespace BirdsiteLive.Pipeline.Processors
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var users = await _twitterUserDal.GetAllTwitterUsersAsync();
|
var users = await _twitterUserDal.GetAllTwitterUsersAsync();
|
||||||
await twitterUsersBufferBlock.SendAsync(users, ct);
|
|
||||||
|
if(users.Length > 0)
|
||||||
|
await twitterUsersBufferBlock.SendAsync(users, ct);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,32 @@ namespace BirdsiteLive.Pipeline.Tests.Processors
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task GetTwitterUsersAsync_NoUsers_Test()
|
||||||
|
{
|
||||||
|
#region Stubs
|
||||||
|
var buffer = new BufferBlock<SyncTwitterUser[]>();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Mocks
|
||||||
|
var twitterUserDalMock = new Mock<ITwitterUserDal>(MockBehavior.Strict);
|
||||||
|
twitterUserDalMock
|
||||||
|
.Setup(x => x.GetAllTwitterUsersAsync())
|
||||||
|
.ReturnsAsync(new SyncTwitterUser[0]);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var processor = new RetrieveTwitterUsersProcessor(twitterUserDalMock.Object);
|
||||||
|
processor.GetTwitterUsersAsync(buffer, CancellationToken.None);
|
||||||
|
|
||||||
|
await Task.Delay(50);
|
||||||
|
|
||||||
|
#region Validations
|
||||||
|
twitterUserDalMock.VerifyAll();
|
||||||
|
Assert.AreEqual(0, buffer.Count);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetTwitterUsersAsync_Exception_Test()
|
public async Task GetTwitterUsersAsync_Exception_Test()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue