public void PresentTabs_ShouldPresentTheDefaultNumberOfItems()
        {
            //Arrange

            var tabKey = "diamond-rings";
            var tabId = "engagement-rings";

            var xmlSource = new XmlSourceFactory();
            var tabsRepository = new TabsRepository(xmlSource);
            var jewelryRepository = new JewelRepository(new SettingManager());
            var fileSystem = new FileSystem();
            var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>();
            var mapper = MockRepository.GenerateStub<IMappingEngine>();

            TabsController controller = new TabsController(tabsRepository,jewelryRepository,fileSystem,xmlSource,pathBarGenerator, mapper);

            var viewModel = MockRepository.GenerateStub<TabsViewModel>();
            viewModel.TabKey = tabKey;
            viewModel.TabId = tabId;

            //Act

            var resultview = controller.SearchTabs(viewModel);

            //Assert

            var model = resultview.Model as TabsViewModel;

            model.JewelryInTabContainersCollection.Count.ShouldBe(10);
        }
        public void FilterJewelryItemsBy_ShouldOnlyReturnTheRightMetalMediaAllMetals()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);

            //Act

            jewelRepository.FilterMediaByMetal(JewelMediaType.All);

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);
            //Assert

            jewelrylist.Should().HaveCount(10);
        }
        public void FilterJewelryItemsBy_ShouldOnlyReturnNineWhiteGoldAndOneYellowGoldMetalString()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);

            //Act

            jewelRepository.FilterMediaByMetal(JewelMediaType.All);

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);
            //Assert

            jewelrylist.Where(x => x.MetalFullName() == "White Gold 18 Karat").Should().HaveCount(9);
            jewelrylist.Where(x => x.MetalFullName() == "Yellow Gold 18 Karat").Should().HaveCount(1);
        }
        public void CurrentPage_ShouldReturnTheCurrentPage()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);
            jewelRepository.ItemsPerPage(3);
            jewelRepository.Page(2);
            //Act

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);

            var currectpage = jewelRepository.CurrentPage;

            //Assert

            currectpage.Should().Be(2);
        }
        public void FilterJewelryItemsBy_ShouldOnlyReturnTheRightMetalMediaWhiteGold()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);

            //Act

            jewelRepository.FilterMediaByMetal(JewelMediaType.WhiteGold);

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);
            //Assert

            jewelrylist.Should().OnlyContain(x => x.Media.IconURLForWebDisplay.Contains("wg")).And.HaveCount(9);
        }
        public void TotalItems_ShouldReturnTheTotalNumbersOfItems()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);

            //Act

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);

            var totalitems = jewelRepository.TotalItems;

            //Assert

            totalitems.Should().Be(10);
        }
        public void Pages_ShouldReturnTheRightAmountOfPages()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);
            jewelRepository.ItemsPerPage(3);
            jewelRepository.Page(2);
            //Act

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);

            //Assert
            jewelrylist.Should().HaveCount(3);
        }
        public void OrderJewelryItemsBy_ShouldReturnTheItemsInTheCorrectOrderByFilterPriceDesc()
        {
            //Arrange
            var dynamicSQL = DynamicSQLWhereObject();

            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");

            JewelRepository jewelRepository = new JewelRepository(settingManager);

            DynamicOrderBy orderBy = new DynamicOrderBy("price","desc");

            //Act
            jewelRepository.OrderJewelryItemsBy(orderBy);

            var jewelrylist = jewelRepository.GetJewelsByDynamicSQL(dynamicSQL);
            //Assert
            var first = jewelrylist[0].Price;
            var last = jewelrylist[jewelrylist.Count - 1].Price;

            first.Should().Be(7500);
            last.Should().Be(1500);
        }
        public void GetJewelByID_ShouldReturnTheRightMediaSetYellowGold()
        {
            //Arrange
            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");
            settingManager.Stub(x => x.GetJewelryBaseDiskPath()).Return(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\");

            JewelRepository jewelRepository = new JewelRepository(settingManager);
            //Act
            var jewel = jewelRepository.GetJewelByID(59325);
            //Assert
            jewel.MediaSetsOwnedByJewel.Should().Be(JewelMediaType.YellowGold);
        }
        public void GetJewelByID_ShouldReturnNullIfYellowGoldRequestedButBotPresent()
        {
            //Arrange
            settingManager.Stub(x => x.GetJewelryBaseWebPath()).Return("/jon-images/jewel/");
            settingManager.Stub(x => x.GetJewelryBaseDiskPath()).Return(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\");

            JewelRepository jewelRepository = new JewelRepository(settingManager);
            jewelRepository.FilterMediaByMetal(JewelMediaType.YellowGold);
            //Act
            var jewel = jewelRepository.GetJewelByID(59324);
            //Assert
            jewel.Should().BeNull();
        }
        public void PresentTabs_ShouldReturntheRightNumberOfItemsAfterMetalWhiteGoldFilter()
        {
            //Arrange

            var tabKey = "diamond-rings";
            var tabId = "engagement-rings";

            var xmlSource = new XmlSourceFactory();
            var tabsRepository = new TabsRepository(xmlSource);
            var jewelryRepository = new JewelRepository(new SettingManager());
            var fileSystem = new FileSystem();
            var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>();

            var mapper = MockRepository.GenerateStub<IMappingEngine>();

            TabsController controller = new TabsController(tabsRepository, jewelryRepository, fileSystem, xmlSource,pathBarGenerator, mapper);

            var viewModel = new TabsViewModel();
            viewModel.TabKey = tabKey;
            viewModel.TabId = tabId;
            viewModel.MetalFilter = JewelMediaType.WhiteGold;

            //Act

            var resultview = controller.SearchTabs(viewModel);

            //Assert
            var model = resultview.Model as TabsViewModel;

            model.JewelryInTabContainersCollection.Should().HaveCount(9).And.OnlyContain(x=> x.PictureURL.Contains("wg"));
        }