public void GetTabsCollectionByKey_ShouldRaiseExceptionIfXmlIsNull()
        {
            var xmlSourceFactory = MockRepository.GenerateStub<IXmlSourceFactory>();
            xmlSourceFactory.Stub(x => x.TabSource()).Return(null);

            var tabrepository = new TabsRepository(xmlSourceFactory);
        }
        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 GetTabCollectionByKey_ShouldReturnTheCorrectCollection()
        {
            var tabrepository = new TabsRepository(fakeXmlSourceFactory);

            var tabs = tabrepository.GetTabsCollectionByKey(TAB_KEY);

            Assert.That(tabs.Count,Is.EqualTo(3));
        }
        public void GetTabCollectionByKey_ShouldReturnTheRightIDWithRightOrder()
        {
            var tabrepository = new TabsRepository(fakeXmlSourceFactory);

            var tabs = tabrepository.GetTabsCollectionByKey(TAB_KEY);

            Assert.That(tabs[0].Id, Is.EqualTo("engagement-rings"));
            Assert.That(tabs[1].Id, Is.EqualTo("diamod-studs"));
            Assert.That(tabs[2].Id, Is.EqualTo("diamod-pendants"));
        }
        public void GetTabCollectionByKey_ShouldReturnTheRightCaptionWithRightOrder()
        {
            var tabrepository = new TabsRepository(fakeXmlSourceFactory);

            var tabs = tabrepository.GetTabsCollectionByKey(TAB_KEY);

            Assert.That(tabs[0].Caption, Is.EqualTo("Rings"));
            Assert.That(tabs[1].Caption, Is.EqualTo("Studs"));
            Assert.That(tabs[2].Caption, Is.EqualTo("Pendants"));
        }
        public void GetTabCollectionByKey_ShouldThrowAnExceptionIfBadKey()
        {
            //Arrange

            var tabrepository = new TabsRepository(fakeXmlSourceFactory);

            tabrepository.GetTabsCollectionByKey(TAB_KEY+"badkey");

            //Act

            //Assert
        }
        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"));
        }
        private TabsController CreateDefaultTabsController()
        {
            var tabsRepository = new TabsRepository(fakeXmlSourceFactory);
            var jewelryRepository = new FakeJewelRepository(new FakeSettingManager());

            var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber();
            var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>();
            var tabsController = new TabsController(tabsRepository, jewelryRepository, fileSystem, fakeXmlSourceFactory,pathBarGenerator, mapper);
            return tabsController;
        }