public void GalleryItemsPromotions_ShouldCallIteServiceGetItemsInPromotion_WhenAllParametersAreValid() { //Arange GalleryItemsViewModel model = new GalleryItemsViewModel(); int pageNumber = 10; var items = new List <Item>(); var colour = MainColourType.Red; var material = MainMaterialType.Swarovski; this.itemServiceMock.Setup(i => i.GetAllItemsInPromotionCount(colour, material)).Returns(It.Is <int>(c => c >= 0)); this.itemServiceMock.Setup(i => i.GetItemsInPromotion( pageNumber, It.IsAny <MainColourType>(), It.IsAny <MainMaterialType>())).Returns(items); var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); // Act var viewResult = itemsController.GalleryItemsPromotions(model, pageNumber) as ViewResult; // Assert this.itemServiceMock.Verify(i => i.GetItemsInPromotion( pageNumber, It.IsAny <MainColourType>(), It.IsAny <MainMaterialType>()), Times.Once); }
public void GalleryItemsPromotions_ShouldThrowArgumentOutOfRangeException_WhenZeroPageNumberIsPassed() { //Arange var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); GalleryItemsViewModel model = new GalleryItemsViewModel(); int invalidPageNumber = 0; //Act & Assert var viewResult = itemsController.GalleryItemsPromotions(model, invalidPageNumber) as ViewResult; }
public void GalleryItemsPromotions_ShouldReturnViewNotNull() { //Arange var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); GalleryItemsViewModel model = new GalleryItemsViewModel(); int pageNumber = 1; //Act var viewResult = itemsController.GalleryItemsPromotions(model, pageNumber) as ViewResult; //Assert Assert.IsNotNull(viewResult); }