public async Task GivenTankWithoutUserId_ReturnsEmptyCollection() { // Arrange var query = new GetTanksByUserIdQuery { UserId = Guid.NewGuid() }; var tankOne = new TankEntity { Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; var tankTwo = new TankEntity { Id = Guid.NewGuid(), UserId = Guid.NewGuid() }; await _tankCollection.InsertManyAsync(new [] { tankOne, tankTwo }); // Act var result = await _classUnderTest.Handle(query, CancellationToken.None); // Assert CollectionAssert.IsEmpty(result); }
public async Task GivenTankWithUserId_ReturnsTank() { // Arrange var userId = Guid.NewGuid(); var query = new GetTanksByUserIdQuery { UserId = userId }; var tankOne = new TankEntity { Id = Guid.NewGuid(), UserId = userId }; var tankTwo = new TankEntity { Id = Guid.NewGuid(), UserId = userId }; await _tankCollection.InsertManyAsync(new [] { tankOne, tankTwo }); // Act var result = await _classUnderTest.Handle(query, CancellationToken.None); // Assert Assert.Multiple(() => { Assert.That(result.Count, Is.EqualTo(2)); var resultingTankOne = result.FirstOrDefault(); Assert.That(resultingTankOne, Is.Not.Null); Assert.That(resultingTankOne.Id, Is.EqualTo(tankOne.Id)); var resultingTankTwo = result.LastOrDefault(); Assert.That(resultingTankTwo, Is.Not.Null); Assert.That(resultingTankTwo.Id, Is.EqualTo(tankTwo.Id)); }); }