namespace Tests.Domain.Campsites
{
public class CampsiteImageSearchBehaviour : BaseTest
{
private int _createdImadeId { get { return _imageSetup.Created[8].Id; } }
public void Arrange_n_images_in_storage(int amountOfImages)
{
_nHibernateHelper.TruncateTableCampsiteImages();
_imageSetup.Add(amountOfImages).Persist();
}
private CampsiteImageSearchDescription Get_search_desc_for_id(int imageId)
{
var searchDesc = new CampsiteImageSearchDescription();
searchDesc.Filter.CampsiteImageIds.Add(imageId);
return searchDesc;
}
[Test]
public void Should_retrieve_pager_from_search()
{
Arrange_n_images_in_storage(10);
var searchDesc = Get_search_desc_for_id(_createdImadeId);
_campsiteImageService.GetBy(searchDesc);
Assert.That(searchDesc.PageCount, Is.EqualTo(1));
Assert.That(searchDesc.TotalItems, Is.EqualTo(1));
}
[Test]
public void Should_return_image_by_id_using_search_description()
{
Arrange_n_images_in_storage(10);
var searchDesc = Get_search_desc_for_id(_createdImadeId);
var campsiteImages = _campsiteImageService.GetBy(searchDesc);
Assert.That(campsiteImages.Count, Is.EqualTo(1));
Assert.That(campsiteImages[0].Id, Is.EqualTo(_createdImadeId));
}
}
}