Пример #1
0
        public void GalleryItemsNew_ShouldCallIteServiceGetNewestItems_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.GetAllItemsCount(colour, material)).Returns(It.Is <int>(c => c >= 0));
            this.itemServiceMock.Setup(i => i.GetNewestItems(
                                           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.GalleryItemsNew(model, pageNumber) as ViewResult;

            // Assert
            this.itemServiceMock.Verify(i => i.GetNewestItems(
                                            pageNumber,
                                            It.IsAny <MainColourType>(),
                                            It.IsAny <MainMaterialType>()), Times.Once);
        }
Пример #2
0
        public void GalleryItemsNew_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.GalleryItemsNew(model, invalidPageNumber) as ViewResult;
        }
Пример #3
0
        public void SingleItem_ShouldThrowArgumentOutOfRangeException_WhenNegativeItemIdIsPassed()
        {
            //Arange
            var itemsController = new ItemsController(this.itemServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object);

            GalleryItemsViewModel model = new GalleryItemsViewModel();
            int invalidItemId           = -10;

            //Act & Assert
            var viewResult = itemsController.GalleryItemsNew(model, invalidItemId) as ViewResult;
        }
Пример #4
0
        public void GalleryItemsNew_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.GalleryItemsNew(model, pageNumber) as ViewResult;

            //Assert
            Assert.IsNotNull(viewResult);
        }