public void GalleryItems_ShouldCallIteServiceGetItemsOfType_TimesOnce_WhenTypeIsNull() { //Arange GalleryItemsViewModel model = new GalleryItemsViewModel(); int pageNumber = 10; string type = "Necklace"; var items = new List <Item>(); var colour = MainColourType.Red; var material = MainMaterialType.Swarovski; this.itemServiceMock.Setup(i => i.GetItemsOfTypeCount(It.IsAny <ItemType>(), colour, material)).Returns(It.Is <int>(c => c >= 0)); this.itemServiceMock.Setup(i => i.GetItemsOfType( pageNumber, It.Is <ItemType>(t => t.ToString() == type), 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.GalleryItems(model, pageNumber, type) as ViewResult; // Assert this.itemServiceMock.Verify(i => i.GetItemsOfType( pageNumber, It.Is <ItemType>(t => t.ToString() == type), It.IsAny <MainColourType>(), It.IsAny <MainMaterialType>()), Times.Once); }
public void GalleryItems_ShouldThrowArgumentOutOfRangeException_WhenZeroPageNumberIsPassed() { //Arange var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); GalleryItemsViewModel model = new GalleryItemsViewModel(); int invalidPageNumber = 0; string type = "Necklace"; //Act & Assert var viewResult = itemsController.GalleryItems(model, invalidPageNumber, type) as ViewResult; }
public void GalleryItems_ShouldThrowArgumentNullException_WhenTypeIsNull() { //Arange var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); GalleryItemsViewModel model = new GalleryItemsViewModel(); int pageNumber = 10; string type = null; //Act & Assert var viewResult = itemsController.GalleryItems(model, pageNumber, type) as ViewResult; }
public void GalleryItems_ShouldReturnViewNotNull() { //Arange var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object); GalleryItemsViewModel model = new GalleryItemsViewModel(); int pageNumber = 1; string type = "Necklace"; //Act var viewResult = itemsController.GalleryItems(model, pageNumber, type) as ViewResult; //Assert Assert.IsNotNull(viewResult); }