예제 #1
0
        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);
        }
예제 #3
0
        public void GetTabCollectionByKey_ShouldReturnTheCorrectCollection()
        {
            var tabrepository = new TabsRepository(fakeXmlSourceFactory);

            var tabs = tabrepository.GetTabsCollectionByKey(TAB_KEY);

            Assert.That(tabs.Count,Is.EqualTo(3));
        }
예제 #4
0
        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"));
        }
예제 #5
0
        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"));
        }
예제 #6
0
        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"));
        }
예제 #8
0
        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;
        }