示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }