public void MediaSetList_ShouldReturn1SetBecauseIconDoesntExistOnOneOfTheSets() { //Arrange const string itemNumber = "0101-15001"; const JewelMediaType jewelMediaSets = JewelMediaType.All; var fakeFileSystem = FakeFileSystem.MediaFileSystemForItemNumber(new Dictionary<string, MockFileData>() { {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-pic-wg.jpg",itemNumber),new MockFileData("")}, // {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-icon-wg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-hand-wg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-hires-wg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-mov-wg.flv",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-pic-yg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-icon-yg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-hand-yg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-hires-yg.jpg",itemNumber),new MockFileData("")}, {String.Format(@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\{0}-mov-yg.flv",itemNumber),new MockFileData("")} }); var settingManager = new FakeSettingManager(); var mediaSetBuilder = new MediaSetBuilder( settingManager, fakeFileSystem); //Act var mediaSetList = mediaSetBuilder.Build(itemNumber, jewelMediaSets); //Assert mediaSetList.Should().HaveCount(1); }
public void MediaSetList_ShouldReturn2SetsBecauseTheFileExist() { //Arrange const string itemNumber = "0101-15001"; const JewelMediaType jewelMediaSets = JewelMediaType.All; var fakeFileSystem = FakeFileSystem.MediaFileSystemForItemNumber(); var settingManager = new FakeSettingManager(); var mediaSetBuilder = new MediaSetBuilder(settingManager, fakeFileSystem); //Act var mediaSetList = mediaSetBuilder.Build(itemNumber,jewelMediaSets); //Assert mediaSetList.Should().HaveCount(2); }
public void EmailToAdmin_ShouldCallTheUserMailerWithTheCorrectEmailForAdmin() { //Arrange var currectEmailForAdmin = new FakeSettingManager().AdminEmail(); var mailer = MockRepository.GenerateMock<IUserMailer>(); mailer.Expect(x => x.BestOfferAdmin(Arg<string>.Is.Equal(currectEmailForAdmin), Arg<BestOfferEmailTemplateViewModel>.Is.Anything)); var bestOfferViewModel = DefaultBestOfferViewModelWithRealJewel(); var bestOffer = CreateDefaultBestOffer(mailer); //Act bestOffer.EmailToAdmin(bestOfferViewModel); //Assert mailer.VerifyAllExpectations(); }
public void AskQuestion_ShouldReturnAJsonWithErrorIfMailerThrowsException() { //Arrange var wishListBuilder = MockRepository.GenerateStub<IViewModelBuilder>(); wishListBuilder.Stub(x => x.Build()).Return(new WishListViewModel()); var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var settingManager = new FakeSettingManager(); var userMailer = MockRepository.GenerateStub<IUserMailer>(); userMailer.Stub( y => y.AskQuestionAdminVersion(Arg<string>.Is.Anything, Arg<AskQuestionEmailTemplateViewModel>.Is.Anything)).Throw(new Exception()); var conrtoller = new ServicesController(wishListBuilder, pathBarGenerator, userMailer, settingManager); //Act var result = conrtoller.AskQuestion("name", "email", "phone", "question") as JsonResult; //Assert var actual = result.Data as OporationWithoutReturnValueJsonModel; actual.HasError.Should().BeTrue(); }
private JewelryItemController CreateJewelryItemControllerWithCustomWishListPersistence( IWishListPersistence wishListPersistence) { var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421"); var settingManager = new FakeSettingManager(); var jewelryRepository = new FakeJewelRepository(settingManager); var webHelpers = GetWebHelpers(); var mediaSetBuilder = GetMediaSetBuilder(); var bestOffer = MockRepository.GenerateStub<IBestOffer>(); var fakeTestimonailRepository = new FakeTestimonialRepository(mapper); var fakeMailer = MockRepository.GenerateStub<IUserMailer>(); var pathbarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var controller = new JewelryItemController(jewelryRepository, mediaSetBuilder, webHelpers, fileSystem, bestOffer, wishListPersistence, fakeTestimonailRepository, fakeMailer, pathbarGenerator, mapper); return controller; }
private JewelryItemController CreateDefaultJewelryItemControllerSetup() { var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber(Tests.FAKE_JEWEL_ITEMNUMBER); var settingManager = new FakeSettingManager(); var jewelryRepository = new FakeJewelRepository(settingManager); var webHelpers = GetWebHelpers(); var mediaSetBuilder = GetMediaSetBuilder(); var fakeTestimonailRepository = new FakeTestimonialRepository(mapper); var bestOffer = MockRepository.GenerateStub<IBestOffer>(); var wishListPersistence = MockRepository.GenerateStub<IWishListPersistence>(); var fakeMailer = MockRepository.GenerateStub<IUserMailer>(); var pathbarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var controller = new JewelryItemController(jewelryRepository, mediaSetBuilder, webHelpers, fileSystem, bestOffer, wishListPersistence, fakeTestimonailRepository, fakeMailer, pathbarGenerator, mapper); return controller; }
private TabsViewModelBuilder CreateDefaultTabsViewModelBuilderWithSpecialTabs() { var settingManager = new FakeSettingManager(); var tabsRepository = CreateStubTabsRepository(TabKey); var jewelryRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421"); TabsViewModelBuilder tabsViewModelBuilder = new TabsViewModelBuilder(TAB_KEY, SPECIAL_TABID1, xmldoc_specialtab, tabsRepository, jewelryRepository, fileSystem); return tabsViewModelBuilder; }
private TabsViewModelBuilder CreateDefaultTabsViewModelBuilderWithCustomInTabFilter() { var settingManager = new FakeSettingManager(); var tabsRepository = CreateStubTabsRepository(TabKey); var jewelryRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421"); TabsViewModelBuilder tabsViewModelBuilder = new TabsViewModelBuilder(TAB_KEY, TAB_ID1, xmldoc_tabswithintabfilter, tabsRepository, jewelryRepository, fileSystem); return tabsViewModelBuilder; }
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 void MapJewelsToInTabContainers_ShouldReturnHasMovieToBeFalseWhenMovieFileIsNotPresent() { //Arrange var settingManager = new FakeSettingManager(); var tabsRepository = CreateStubTabsRepository(TabKey); var jewelryRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber(new Dictionary<string, MockFileData>() { {@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\0101-15421-pic-wg.jpg",new MockFileData("")}, {@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\0101-15421-icon-wg.jpg",new MockFileData("")}, {@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\0101-15421-hires-wg.jpg",new MockFileData("")}, {@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\0101-15421-hand-wg.jpg",new MockFileData("")}, // {@"C:\Users\maMLUka\Documents\jewelryonnet\internet-sites\jon-images\jewelry\0101-15421-mov-wg.flv",new MockFileData("")} }); TabsViewModelBuilder tabsViewModelBuilder = new TabsViewModelBuilder(TAB_KEY, TAB_ID1, xmldoc_regular3tabs, tabsRepository, jewelryRepository, fileSystem); var viewModel = tabsViewModelBuilder.Build(); //Act var tabContainer1 = viewModel.JewelryInTabContainersCollection[0]; //Assert tabContainer1.HasMovie.Should().BeFalse(); }
public void AskQuestion_ShouldSendTheEmailToTheAdmin() { //Arrange var wishListBuilder = MockRepository.GenerateStub<IViewModelBuilder>(); wishListBuilder.Stub(x => x.Build()).Return(new WishListViewModel()); var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var settingManager = new FakeSettingManager(); var adminEmailAddress = settingManager.AdminEmail(); var userMailer = MockRepository.GenerateMock<IUserMailer>(); userMailer.Expect( y => y.AskQuestionAdminVersion(Arg<string>.Is.Equal(adminEmailAddress), Arg<AskQuestionEmailTemplateViewModel>.Matches( x => x.Email == "email" && x.Name == "name" && x.Phone == "phone" && x.Question == "question"))).Repeat.Once(); var conrtoller = new ServicesController(wishListBuilder, pathBarGenerator, userMailer, settingManager); //Act var result = conrtoller.AskQuestion("name","email","phone","question"); //Assert userMailer.VerifyAllExpectations(); }
private static ServicesController CreateDefaultServicesController() { var wishListBuilder = MockRepository.GenerateStub<IViewModelBuilder>(); wishListBuilder.Stub(x => x.Build()).Return(new WishListViewModel()); var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var userMailer = MockRepository.GenerateStub<IUserMailer>(); var settingManager = new FakeSettingManager(); var conrtoller = new ServicesController(wishListBuilder, pathBarGenerator, userMailer, settingManager); return conrtoller; }
private BestOffer CreateDefaultBestOffer(IUserMailer mailer) { var settingManager = new FakeSettingManager(); var jewelRepository = new FakeJewelRepository(new FakeSettingManager()); var bestOffer = new BestOffer(mailer, settingManager, jewelRepository, mapper); return bestOffer; }
private JewelryItemViewModelBuilder JewelryItemViewModelBuilderFactoryMethod( Dictionary<string, MockFileData> files ) { var settingManager = new FakeSettingManager(); var fakeRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber(files); var fakeTestimonailRepository = new FakeTestimonialRepository(mapper); var builder = new JewelryItemViewModelBuilder(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, fakeRepository,fakeTestimonailRepository, fileSystem,mapper); return builder; }
private TabsViewModelBuilder CreateDefaultTabsViewModelBuilderWithAllMetalFilter() { var settingManager = new FakeSettingManager(); var tabsRepository = CreateStubTabsRepository(TabKey); var jewelryRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421"); var model = new TabsViewModel() { MetalFilter = JewelMediaType.All, TabKey = TabKey, TabId = TabID1 }; TabsViewModelBuilder tabsViewModelBuilder = new TabsViewModelBuilder(model, xmldoc_regular3tabs, tabsRepository, jewelryRepository, fileSystem); return tabsViewModelBuilder; }
private JewelryItemViewModelBuilder JewelryItemViewModelBuilderFactoryMethodWithJewelID(int jewelD) { var settingManager = new FakeSettingManager(); var fakeRepository = new FakeJewelRepository(settingManager); var fileSystem = FakeFileSystem.MediaFileSystemForItemNumber("0101-15421"); var fakeTestimonailRepository = new FakeTestimonialRepository(mapper); var builder = new JewelryItemViewModelBuilder(jewelD, fakeRepository, fakeTestimonailRepository,fileSystem,mapper); return builder; }
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; }