public EndViewModelBuilder(CustomJewelPersistenceInEndPage customJewelPersistenceInEndPage, TabsForJewelDesignNavigationBuilder tabsForJewelDesignBuilder, IDiamondRepository diamondRepository, IJewelRepository jewelRepository, IMappingEngine mapper)
 {
     this.customJewelPersistenceInEndPage = customJewelPersistenceInEndPage;
     this.tabsForJewelDesignBuilder = tabsForJewelDesignBuilder;
     this.diamondRepository = diamondRepository;
     this.jewelRepository = jewelRepository;
     this.mapper = mapper;
 }
 public DiamondViewModelBuilder(CustomJewelPersistenceInDiamond customJewelPersistence, TabsForJewelDesignNavigationBuilder tabsForJewelDesignNavigationBuilder, IDiamondRepository diamondRepository, DiamondHelpBuilder diamondHelpBuilder, IMappingEngine mapper)
 {
     this.customJewelPersistence = customJewelPersistence;
     this.diamondRepository = diamondRepository;
     this.diamondHelpBuilder = diamondHelpBuilder;
     this.tabsForJewelDesignNavigationBuilder = tabsForJewelDesignNavigationBuilder;
     this.mapper = mapper;
 }
        public ActionResult ChooseSetting(ChooseSettingViewModel chooseSettingViewModel )
        {
            var tabsource = xmlSourceFactory.TabSource();

            var tabsViewModelBuilder = new TabsViewModelBuilder(chooseSettingViewModel, tabsource, tabsRepository, jewelRepository, fileSystem);

            var tabsForJewelNavigation = new TabsForJewelDesignNavigationBuilder(chooseSettingViewModel, diamondRepository,
                                                                    jewelRepository, webHelpers);

            tabsForJewelNavigation.WhichTabToHighLight(NagivationTabType.ChooseSetting);

            var builder = new ChooseSettingViewModelBuilder(chooseSettingViewModel, tabsViewModelBuilder, tabsForJewelNavigation);

            var viewModel = builder.Build();

            viewModel.PathBarItems = pathBarGenerator.GenerateUsing<TabsPathBarResolver, ITabsViewModel>(viewModel);

            return View(viewModel);
        }
        public void Build_ShouldReturnAJavaScriptJsonInitializerWithReportForTheSearchInitBecauseItWasSpecifiedInTheRouteDic()
        {
            var customJewel = new CustomJewelPersistenceForDiamondSearch();
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());

            webHelpers.Stub(x => x.RouteUrl(Arg<string>.Is.Anything, Arg<RouteValueDictionary>.Is.Anything)).Return(
                Tests.STRING_THAT_HAS_NO_MEANING_IN_THIS_CONTEXT);

            customJewel.Report = Tests.STRING_THAT_IS_ASSERTED_BUT_HAS_NO_MEANING;

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);

            var builder = new DiamondSearchViewModelBuilder(customJewel, tabsForJewelDesignBuilder);
            //Act
            var viewModel = builder.Build();
            //Assert
            viewModel.JSONClientScriptInitializer["Report"].Should().Be(Tests.STRING_THAT_IS_ASSERTED_BUT_HAS_NO_MEANING);
        }
        public void Build_DiamondTabShouldReturnModifyRouteAndCallTheRightRouteIfDiamondIsPresent()
        {
            //Arrange
            var customJewel = new CustomJewelPersistenceBase();
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateMock<IWebHelpers>();
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());

            customJewel.DiamondID = FIRST_DIAMOND_IN_REP;

            webHelpers.Expect(
                x =>
                x.RouteUrl(Arg<string>.Is.Equal("DiamondSearch"),
                           Arg<RouteValueDictionary>.Matches(d => (int)d["DiamondID"] == customJewel.DiamondID && (int)d["SettingID"] == customJewel.SettingID))).
                Return("/JewelDesign/DiamondSearch").Repeat.Any();

            var builder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);
            //Act
            var tabs = builder.Build();
            //Assert
            tabs[0].ModifyRoute.Should().Be("/JewelDesign/DiamondSearch");
            webHelpers.VerifyAllExpectations();
        }
        public void Build_ShouldReturnAJavaScriptJsonInitializerWithSettingIDBecauseItWasSpecifiedInTheRouteDic()
        {
            var customJewel = new CustomJewelPersistenceForDiamondSearch();
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());

            webHelpers.Stub(x => x.RouteUrl(Arg<string>.Is.Anything, Arg<RouteValueDictionary>.Is.Anything)).Return(
                Tests.STRING_THAT_HAS_NO_MEANING_IN_THIS_CONTEXT);

            customJewel.DiamondID = FIRST_DIAMOND_IN_REP;
            customJewel.SettingID = SETTING_ID;

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);

            var builder = new DiamondSearchViewModelBuilder(customJewel, tabsForJewelDesignBuilder);
            //Act
            var viewModel = builder.Build();
            //Assert
            viewModel.JSONClientScriptInitializer["SettingID"].Should().Be(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID.ToString());
        }
        public ActionResult Setting(CustomJewelPersistenceForSetting customJewelPersistenceForSetting)
        {
            var tabsForJewelNavigation = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceForSetting, diamondRepository,
                                                                     jewelRepository, webHelpers);

            tabsForJewelNavigation.WhichTabToHighLight(NagivationTabType.ChooseSetting);

            jewelRepository.FilterMediaByMetal(customJewelPersistenceForSetting.MediaType == 0 ? JewelMediaType.WhiteGold : customJewelPersistenceForSetting.MediaType);

            var jewelryItemViewModelBuilder = new JewelryItemViewModelBuilder(customJewelPersistenceForSetting.SettingID, jewelRepository,testimonialRepository ,fileSystem,mapper);

            var builder = new SettingViewModelBuilder(customJewelPersistenceForSetting, tabsForJewelNavigation, jewelryItemViewModelBuilder);

            var viewModel = builder.Build();

            viewModel.PathBarItems = pathBarGenerator.GenerateUsing<UsingDynamicTitlePathBarResolver, dynamic>(viewModel);

            return View(viewModel);
        }
        public ActionResult End(CustomJewelPersistenceInEndPage customJewelPersistenceInEndPage)
        {
            if (customJewelPersistenceInEndPage.MediaType == 0 )
            {
                customJewelPersistenceInEndPage.MediaType = JewelMediaType.WhiteGold;
            }

            var tabsForJewelNavigation = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceInEndPage, diamondRepository,
                                                                                    jewelRepository, webHelpers);

            tabsForJewelNavigation.WhichTabToHighLight(NagivationTabType.YourOrder);

            var builder = new EndViewModelBuilder(customJewelPersistenceInEndPage, tabsForJewelNavigation, diamondRepository,
                                                 jewelRepository, mapper);

            var viewModel = builder.Build();

            return View(viewModel);
        }
        public ActionResult DiamondSearch(CustomJewelPersistenceForDiamondSearch customJewelPersistenceBaseClass)
        {
            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceBaseClass, diamondRepository,
                                                                          jewelRepository, webHelpers);

            tabsForJewelDesignBuilder.WhichTabToHighLight(NagivationTabType.YourDiamond);

            var builder = new DiamondSearchViewModelBuilder(customJewelPersistenceBaseClass, tabsForJewelDesignBuilder);

            var viewModel = builder.Build();

            return View(viewModel);
        }
        public ActionResult Diamond(CustomJewelPersistenceInDiamond customJewelPersistenceInDiamond)
        {
            var tabsForJewelNavigation = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceInDiamond, diamondRepository,
                                                                                 jewelRepository, webHelpers);

            tabsForJewelNavigation.WhichTabToHighLight(NagivationTabType.YourDiamond);

            var builder = new DiamondViewModelBuilder(customJewelPersistenceInDiamond,tabsForJewelNavigation,diamondRepository, diamondHelpBuilder,mapper);
            var viewModel = builder.Build();

            viewModel.PathBarItems = pathBarGenerator.GenerateUsing<UsingDynamicTitlePathBarResolver, dynamic>(viewModel);

            return View(viewModel);
        }
        private TabsForJewelDesignNavigationBuilder CreateWithDiamondIDTabsForJewelDesignBuilder()
        {
            var customJewel = new CustomJewelPersistenceBase();
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());
            webHelpers.Stub(x => x.RouteUrl(Arg<string>.Is.Anything, Arg<RouteValueDictionary>.Is.Anything)).Return(
                "not important for this test");

            customJewel.DiamondID = FIRST_DIAMOND_IN_REP;

            var builder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);
            return builder;
        }
        private ChooseSettingViewModelBuilder CreateDefaultChooseSettingViewModelBuilderWithChooseSettingModelAsAParameter(ChooseSettingViewModel chooseSettingViewModel)
        {
            var settingManager = new FakeSettingManager();
            var tabsRepository = TabsViewModelBuilderTests.CreateStubTabsRepository(JEWEL_DESIGN_TABKEY);
            var jewelryRepository = new FakeJewelRepository(settingManager);

            var fakeTabXmlFactory = new FakeTabXmlFactory();
            var xmldoc_jeweldesign = fakeTabXmlFactory.JewelDesign3Tabs(JEWEL_DESIGN_TABKEY);

            var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421");

            TabsViewModelBuilder tabsViewModelBuilder = new TabsViewModelBuilder(chooseSettingViewModel,
                                                                                 xmldoc_jeweldesign,
                                                                                 tabsRepository, jewelryRepository, fileSystem);

            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(chooseSettingViewModel,
                                                                                    diamondRepository, jewelryRepository,
                                                                                    webHelpers);

            var builder = new ChooseSettingViewModelBuilder(chooseSettingViewModel, tabsViewModelBuilder, tabsForJewelDesignBuilder);
            return builder;
        }
 public ChooseSettingViewModelBuilder(ChooseSettingViewModel chooseSettingViewModel, TabsViewModelBuilder tabsViewModelBuilder, TabsForJewelDesignNavigationBuilder tabsForJewelDesignBuilder)
 {
     this.chooseSettingViewModel = chooseSettingViewModel;
     this.tabsViewModelBuilder = tabsViewModelBuilder;
     this.tabsForJewelDesignBuilder = tabsForJewelDesignBuilder;
 }
 private TabsForJewelDesignNavigationBuilder CreateDefaultTabsForJewelDesignBuilderWithPersistenceAsAParameter(CustomJewelPersistenceBase customJewel)
 {
     var diamondRepository = new FakeDiamondRepository(mapper);
     var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
     var jewelRepository = new FakeJewelRepository(new FakeSettingManager());
     var builder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);
     return builder;
 }
        public void Build_ShouldSetTheTabNAvigationModelProperty()
        {
            //Arrange
            var customJewel = new CustomJewelPersistenceForDiamondSearch();
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
            var jewelRepository = new FakeJewelRepository(new FakeSettingManager());

            webHelpers.Stub(x => x.RouteUrl(Arg<string>.Is.Anything, Arg<RouteValueDictionary>.Is.Anything)).Return(
                "not important for this test");

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository, jewelRepository, webHelpers);

            var builder = new DiamondSearchViewModelBuilder(customJewel, tabsForJewelDesignBuilder);
            //Act
            var viewModel = builder.Build();
            //Assert
            viewModel.TabsForJewelDesignNavigation.Should().HaveCount(3);
        }
 public SettingViewModelBuilder(CustomJewelPersistenceForSetting customJewelForSetting, TabsForJewelDesignNavigationBuilder tabsForJewelDesignBuilder, JewelryItemViewModelBuilder jewelryItemViewModelBuilder)
 {
     this.customJewelForSetting = customJewelForSetting;
     this.tabsForJewelDesignBuilder = tabsForJewelDesignBuilder;
     this.jewelryItemViewModelBuilder = jewelryItemViewModelBuilder;
 }
        private SettingViewModelBuilder CreateDefaultSettingViewModelBuilderWithCustomModel(CustomJewelPersistenceForSetting customJewelForSetting)
        {
            var settingManager = new FakeSettingManager();
            var jewelryRepository = new FakeJewelRepository(settingManager);
            var diamondRepository = new FakeDiamondRepository(mapper);
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewelForSetting,
                                                                                    diamondRepository, jewelryRepository,
                                                                                    webHelpers);

            var fakeRepository = new FakeJewelRepository(settingManager);

            var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421");

            var fakeTestimonialRepository = new FakeTestimonialRepository(mapper);

            var jewelryItemViewModelBuilder = new JewelryItemViewModelBuilder(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID,
                                                                              fakeRepository, fakeTestimonialRepository,
                                                                              fileSystem, mapper);

            var builder = new SettingViewModelBuilder(customJewelForSetting, tabsForJewelDesignBuilder,
                                                      jewelryItemViewModelBuilder);
            return builder;
        }
        private EndViewModelBuilder CreateDefaultEditViewModelBuilderWithPresistenceAs(CustomJewelPersistenceInEndPage customJewelPersistenceInEndPage)
        {
            var diamondRepository = new FakeDiamondRepository(mapper);

            var jewelryRepository = new FakeJewelRepository(new SettingManager());
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceInEndPage, diamondRepository,
                                                                                    jewelryRepository, webHelpers);

            var builder = new EndViewModelBuilder(customJewelPersistenceInEndPage, tabsForJewelDesignBuilder, diamondRepository,
                                                   jewelryRepository, mapper);
            return builder;
        }
        //TODO add the tests for the mapping to be mapper agnostic
        private EndViewModelBuilder CreateDefaultEditViewModelBuilder()
        {
            var diamondRepository = new FakeDiamondRepository(mapper);

            var jewelryRepository = new FakeJewelRepository(new SettingManager());
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();

            var customJewelInEndPage = new CustomJewelPersistenceInEndPage();

            customJewelInEndPage.DiamondID = 1;
            customJewelInEndPage.SettingID = Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID;
            customJewelInEndPage.MediaType = JewelMediaType.YellowGold;
            customJewelInEndPage.Size = Tests.SAMPLE_JEWEL_SIZE_725;

            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewelInEndPage, diamondRepository,
                                                                                    jewelryRepository, webHelpers);

            var builder = new EndViewModelBuilder(customJewelInEndPage, tabsForJewelDesignBuilder, diamondRepository,
                                                   jewelryRepository,mapper);
            return builder;
        }
 public DiamondSearchViewModelBuilder(CustomJewelPersistenceForDiamondSearch customJewelPersistenceForDiamondSearch, TabsForJewelDesignNavigationBuilder tabsForJewelDesignNavigationBuilder)
 {
     this.customJewelPersistenceForDiamondSearch = customJewelPersistenceForDiamondSearch;
     this.tabsForJewelDesignNavigationBuilder = tabsForJewelDesignNavigationBuilder;
 }
        private DiamondViewModelBuilder CreateDefaultDiamondViewModelBuilderWithCustomJewelPersistenceAsAParameter(CustomJewelPersistenceInDiamond customJewel)
        {
            var diamondRepository = new FakeDiamondRepository(mapper);
            var jewelryRepository = new FakeJewelRepository(new FakeSettingManager());
            var diamondHelpBuilder = new DiamondHelpBuilder(new FakeXmlSourceFactory());
            var webHelpers = MockRepository.GenerateStub<IWebHelpers>();
            var tabsForJewelDesignBuilder = new TabsForJewelDesignNavigationBuilder(customJewel, diamondRepository,
                                                                          jewelryRepository, webHelpers);

            var builder = new DiamondViewModelBuilder(customJewel, tabsForJewelDesignBuilder, diamondRepository, diamondHelpBuilder, mapper);
            return builder;
        }