/// <summary> /// Fakes the ceremony. /// </summary> /// <param name="count">The count.</param> /// <param name="ceremonyRepository">The ceremony repository.</param> /// <param name="specificCeremonies">The specific ceremonies.</param> public static void FakeCeremony(int count, IRepository<Ceremony> ceremonyRepository, List<Ceremony> specificCeremonies) { var ceremonies = new List<Ceremony>(); var specificTransactionsCount = 0; if (specificCeremonies != null) { specificTransactionsCount = specificCeremonies.Count; for (int i = 0; i < specificTransactionsCount; i++) { ceremonies.Add(specificCeremonies[i]); } } for (int i = 0; i < count; i++) { ceremonies.Add(CreateValidEntities.Ceremony(i + specificTransactionsCount + 1)); } var totalCount = ceremonies.Count; for (int i = 0; i < totalCount; i++) { ceremonies[i].SetIdTo(i + 1); int i1 = i; ceremonyRepository .Expect(a => a.GetNullableById(i1 + 1)) .Return(ceremonies[i]) .Repeat .Any(); } ceremonyRepository.Expect(a => a.GetNullableById(totalCount + 1)).Return(null).Repeat.Any(); ceremonyRepository.Expect(a => a.Queryable).Return(ceremonies.AsQueryable()).Repeat.Any(); ceremonyRepository.Expect(a => a.GetAll()).Return(ceremonies).Repeat.Any(); }
public void Setup() { _validEmployee1 = ObjectMother.ValidEmployee("emp1").WithEntityId(1); _validEmployee2 = ObjectMother.ValidEmployee("emp2").WithEntityId(2); _selectedEmployees = new[] { _validEmployee2, _validEmployee2 }; _selectedEntities = new[]{_validEmployee1,_validEmployee2}; dto = new SelectBoxPickerDto{Selected = new[]{"1","2"}}; _repo = MockRepository.GenerateMock<IRepository>(); _repo.Expect(x => x.Find<Employee>(1)).Return(_validEmployee1); _repo.Expect(x => x.Find<Employee>(2)).Return(_validEmployee2); _selectBoxPickerService = new SelectBoxPickerService(_selectListItemService,_repo); _result = _selectBoxPickerService.GetListOfSelectedEntities<Employee>(dto); }
public new void SetUp() { _languageRepo = MockRepository.GenerateMock<IRepository<Language>>(); var lang1 = new Language { Name = "English", LanguageCulture = "en-Us", FlagImageFileName = "us.png", Published = true, DisplayOrder = 1 }; var lang2 = new Language { Name = "Russian", LanguageCulture = "ru-Ru", FlagImageFileName = "ru.png", Published = true, DisplayOrder = 2 }; _languageRepo.Expect(x => x.Table).Return(new List<Language>() { lang1, lang2 }.AsQueryable()); _storeMappingRepo = MockRepository.GenerateMock<IRepository<StoreMapping>>(); var cacheManager = new NopNullCache(); _settingService = MockRepository.GenerateMock<ISettingService>(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _localizationSettings = new LocalizationSettings(); _languageService = new LanguageService(cacheManager, _languageRepo, _storeMappingRepo, _settingService, _localizationSettings, _eventPublisher); }
public void Setup() { products= new List<Product>(); images = new List<Image>(); validator = MockRepository.GenerateStub<IValidatingBinder>(); repository = MockRepository.GenerateStub<IRepository<Product>>(); repository.Expect(x => x.GetAll()).Return(products.AsQueryable()); fileService = MockRepository.GenerateStub<IHttpFileService>(); imageOrderableService = MockRepository.GenerateStub<IOrderableService<ProductImage>>(); fileService.Expect(x => x.GetUploadedImages(null)).IgnoreArguments().Return(images); sizeService = MockRepository.GenerateStub<ISizeService>(); var resolver = MockRepository.GenerateStub<IRepositoryResolver>(); controllerContext = new ControllerContext() { HttpContext = MockRepository.GenerateStub<HttpContextBase>() }; controllerContext.HttpContext.Stub(x => x.Request).Return(MockRepository.GenerateStub<HttpRequestBase>()); sizeService.Expect(x => x.WithValues(controllerContext.HttpContext.Request.Form)).Return(sizeService); valueProvider = new FakeValueProvider(); bindingContext = new ModelBindingContext() { ModelState = new ModelStateDictionary(), ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(Product)), ModelName = "product", ValueProvider = valueProvider }; binder = new ProductBinder(validator, resolver, repository, fileService, imageOrderableService, sizeService); }
public void Setup() { var entity1 = new SolutionFeatureConfig { Id = 1, IsForBPSubmission = true }; var entity2 = new SolutionFeatureConfig { Id = 2, IsForBPSubmission = true }; var entity3 = new SolutionFeatureConfig { Id = 3, IsForBPSubmission = false }; var entity4 = new SolutionFeatureConfig { Id = 4 }; var cacheManager = new NopNullCache(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _solutionFeatureConfigRepo = MockRepository.GenerateMock<IRepository<SolutionFeatureConfig>>(); _solutionFeatureConfigRepo.Expect(x => x.Table).Return(new List<SolutionFeatureConfig> { entity1, entity2, entity3, entity4 }.AsQueryable()); _solutionFeatureConfigService = new SolutionFeatureConfigService(cacheManager, _solutionFeatureConfigRepo, _eventPublisher); }
public void Setup() { _cacheManger = new NopNullCache(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _solFunRepository = MockRepository.GenerateMock<IRepository<SolutionFunder>>(); var solfun1 = new SolutionFunder() { Id = 1, SolutionID = 1, SupplierID = 1 }; var solfun2 = new SolutionFunder() { Id = 2, SolutionID = 2, SupplierID = 1 }; var solfun3 = new SolutionFunder() { Id = 3, SolutionID = 1, SupplierID = 2 }; var solfun4 = new SolutionFunder() { Id = 4, SolutionID = 2, SupplierID = 2 }; var solfun5 = new SolutionFunder() { Id = 5, SolutionID = 3, SupplierID = 2 }; var solfun6 = new SolutionFunder() { Id = 6, SolutionID = 4, SupplierID = 3 }; _solFunRepository.Expect(s => s.Table).Return(new List<SolutionFunder> { solfun1, solfun2, solfun3, solfun4, solfun5, solfun6 }.AsQueryable()); _solFunRepository.Expect(s => s.TableNoTracking).Return(new List<SolutionFunder> { solfun1, solfun2, solfun3, solfun4, solfun5, solfun6 }.AsQueryable()); _solutionFunderService = new SolutionFunderService(_cacheManger, _solFunRepository, _eventPublisher); }
public void Setup() { _field = ObjectMother.ValidField("raif").WithEntityId(1); _field.Size = 1000; _product = ObjectMother.ValidInventoryProductFertilizer("poop").WithEntityId(2); _product.SizeOfUnit = 100; _product.UnitType = UnitType.Lbs.ToString(); var given = new SuperInputCalcViewModel { Field = _field.EntityId.ToString(), Product = _product.EntityId.ToString(), FertilizerRate = 100 }; _repo = MockRepository.GenerateMock<IRepository>(); _repo.Expect(x => x.Find<Field>(Int64.Parse(given.Field))).Return(_field); _repo.Expect(x => x.Find<InventoryProduct>(Int64.Parse(given.Product))).Return(_product); _SUT = new FertilizerNeededCalculator(_repo, new UnitSizeTimesQuantyCalculator(),null); _result = _SUT.Calculate(given); }
public new void SetUp() { _activityType1 = new ActivityLogType { Id = 1, SystemKeyword = "TestKeyword1", Enabled = true, Name = "Test name1" }; _activityType2 = new ActivityLogType { Id = 2, SystemKeyword = "TestKeyword2", Enabled = true, Name = "Test name2" }; _customer1 = new Customer { Id = 1, Email = "[email protected]", Username = "TestUser1", Deleted = false, }; _customer2 = new Customer { Id = 2, Email = "[email protected]", Username = "TestUser2", Deleted = false, }; _activity1 = new ActivityLog { Id = 1, ActivityLogType = _activityType1, CustomerId = _customer1.Id, Customer = _customer1 }; _activity2 = new ActivityLog { Id = 2, ActivityLogType = _activityType1, CustomerId = _customer2.Id, Customer = _customer2 }; _cacheManager = new NopNullCache(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _activityLogRepository = MockRepository.GenerateMock<IRepository<ActivityLog>>(); _activityLogTypeRepository = MockRepository.GenerateMock<IRepository<ActivityLogType>>(); _activityLogTypeRepository.Expect(x => x.Table).Return(new List<ActivityLogType> { _activityType1, _activityType2 }.AsQueryable()); _activityLogRepository.Expect(x => x.Table).Return(new List<ActivityLog> { _activity1, _activity2 }.AsQueryable()); _customerActivityService = new CustomerActivityService(_cacheManager, _activityLogRepository, _activityLogTypeRepository, _workContext, null, null, null, _webHelper); }
public new void SetUp() { _discountRepo = MockRepository.GenerateMock<IRepository<Discount>>(); var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0, }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3, }; _discountRepo.Expect(x => x.Table).Return(new List<Discount>() { discount1, discount2 }.AsQueryable()); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _storeContext = MockRepository.GenerateMock<IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(new Store { Id = 1, Name = "MyStore" }); _settingService = MockRepository.GenerateMock<ISettingService>(); var cacheManager = new NullCache(); _discountRequirementRepo = MockRepository.GenerateMock<IRepository<DiscountRequirement>>(); _discountUsageHistoryRepo = MockRepository.GenerateMock<IRepository<DiscountUsageHistory>>(); var pluginFinder = new PluginFinder(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); _discountService = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo, _discountUsageHistoryRepo, _storeContext, _genericAttributeService, pluginFinder, _eventPublisher, _settingService, base.ProviderManager); }
public new void SetUp() { var cacheManager = new NopNullCache(); _workContext = null; _currencySettings = new CurrencySettings(); var currency1 = new Currency { Id = 1, Name = "Euro", CurrencyCode = "EUR", DisplayLocale = "", CustomFormatting = "€0.00", DisplayOrder = 1, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc= DateTime.UtcNow }; var currency2 = new Currency { Id = 1, Name = "US Dollar", CurrencyCode = "USD", DisplayLocale = "en-US", CustomFormatting = "", DisplayOrder = 2, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc= DateTime.UtcNow }; _currencyRepo = MockRepository.GenerateMock<IRepository<Currency>>(); _currencyRepo.Expect(x => x.Table).Return(new List<Currency>() { currency1, currency2 }.AsQueryable()); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService, _currencySettings, pluginFinder, null); _taxSettings = new TaxSettings(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax"); _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax"); _priceFormatter = new PriceFormatter(_workContext, _currencyService,_localizationService, _taxSettings, _currencySettings); }
public void Setup() { _cacheManger = new NopNullCache(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _solFunFeaRepository = MockRepository.GenerateMock<IRepository<SolutionFeature>>(); var solfunfea1 = new SolutionFeature() { Id = 1, FeatureId = 1 }; var solfunfea2 = new SolutionFeature() { Id = 2, FeatureId = 1 }; var solfunfea3 = new SolutionFeature() { Id = 3, FeatureId = 1 }; var solfunfea4 = new SolutionFeature() { Id = 4, FeatureId = 2 }; var solfunfea5 = new SolutionFeature() { Id = 5, FeatureId = 2 }; _solFunFeaRepository.Expect(s => s.TableNoTracking).Return(new List<SolutionFeature> { solfunfea1, solfunfea2, solfunfea3, solfunfea4, solfunfea5 }.AsQueryable()); _solutionFunderFeatureService = new SolutionFunderFeatureService(_cacheManger, _solFunFeaRepository, _eventPublisher); }
public void Setup() { _poliId = 0; _repo = MockRepository.GenerateMock<IRepository>(); _purchaseOrderLineItem = ObjectMother.ValidPurchaseOrderLineItem("raif"); _inventoryBaseProducts = new List<InventoryProduct> { ObjectMother.ValidInventoryBaseProduct("raif")}.AsQueryable(); _purchaseOrderLineItem.TotalReceived = 4; _repo.Expect(x => x.Query<InventoryProduct>(null)).IgnoreArguments().Return(_inventoryBaseProducts); _saveEntityService = MockRepository.GenerateMock<ISaveEntityService>(); _crudManager = MockRepository.GenerateMock<ICrudManager>(); _crudManager.Expect(x => x.Finish()).Return(new Notification()); _sesCatcher = _saveEntityService.CaptureArgumentsFor(x=>x.ProcessSave(_inventoryBaseProducts.FirstOrDefault(),null),x=>x.Return(_crudManager)); _SUT = new InventoryService(_repo, _saveEntityService); _crudManager = _SUT.ReceivePurchaseOrderLineItem(_purchaseOrderLineItem); }
public void Setup() { _field = ObjectMother.ValidField("raif").WithEntityId(1); _field.Size = 1000; var given = new SuperInputCalcViewModel { Field = _field.EntityId.ToString(), Depth = 10, DitchDepth = 10, DitchlineWidth = 10, Drainageline = 10, PipeRadius = 10 }; _repo = MockRepository.GenerateMock<IRepository>(); _repo.Expect(x => x.Find<Field>(Int64.Parse(given.Field))).Return(_field); _SUT = new MaterialsCalculator(_repo, null); _result = _SUT.Calculate(given); }
public void SetUp() { // you have to be an administrator to access the order controller Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin"), new[] { "Administrator" }); orderRepository = MockRepository.GenerateStub<IRepository<Order>>(); countryRepository = MockRepository.GenerateStub<IRepository<Country>>(); cardTypeRepository = MockRepository.GenerateStub<IRepository<CardType>>(); encryptionService = MockRepository.GenerateStub<IEncryptionService>(); postageService = MockRepository.GenerateStub<IPostageService>(); userService = MockRepository.GenerateStub<IUserService>(); searchService = MockRepository.GenerateStub<IOrderSearchService>(); var mocks = new MockRepository(); statusRepository = MockRepository.GenerateStub<IRepository<OrderStatus>>(); orderController = new OrderController( orderRepository, countryRepository, cardTypeRepository, encryptionService, postageService, userService, searchService, statusRepository ); testContext = new ControllerTestContext(orderController); postageService.Expect(ps => ps.CalculatePostageFor(Arg<Order>.Is.Anything)); userService.Expect(us => us.CurrentUser).Return(new User { UserId = 4, RoleId = Role.AdministratorId }); testContext.TestContext.Context.User = new User { UserId = 4 }; testContext.TestContext.Request.RequestType = "GET"; testContext.TestContext.Request.Stub(r => r.QueryString).Return(new NameValueCollection()); testContext.TestContext.Request.Stub(r => r.Form).Return(new NameValueCollection()); statusRepository.Expect(x => x.GetAll()).Return(new List<OrderStatus>().AsQueryable()); mocks.ReplayAll(); }
public void BeforeEachTest() { _repository = MockRepository.GenerateMock<IRepository>(); sampleService = new SampleService(_repository); _expectedBook = new Book { Title = "Book", Price = 10m }; _expectedAuthor = new Author { Name = "Author" }; _repository.Expect(x => x.Save(_expectedBook)).Repeat.Once(); _actualBook = sampleService.UpdateBook(_expectedBook, _expectedAuthor); }
public static void RegistrationPetitions(int count, IRepository<RegistrationPetition> repository, List<RegistrationPetition> specificRegistrationPetitions) { var registrationPetitions = new List<RegistrationPetition>(); var specificRegistrationPetitionsCount = 0; if (specificRegistrationPetitions != null) { specificRegistrationPetitionsCount = specificRegistrationPetitions.Count; for (int i = 0; i < specificRegistrationPetitionsCount; i++) { registrationPetitions.Add(specificRegistrationPetitions[i]); } } for (int i = 0; i < count; i++) { registrationPetitions.Add(CreateValidEntities.RegistrationPetition(i + specificRegistrationPetitionsCount + 1)); } var totalCount = registrationPetitions.Count; for (int i = 0; i < totalCount; i++) { registrationPetitions[i].SetIdTo(i + 1); int i1 = i; repository .Expect(a => a.GetNullableById(i1 + 1)) .Return(registrationPetitions[i]) .Repeat .Any(); } repository.Expect(a => a.GetNullableById(totalCount + 1)).Return(null).Repeat.Any(); repository.Expect(a => a.Queryable).Return(registrationPetitions.AsQueryable()).Repeat.Any(); repository.Expect(a => a.GetAll()).Return(registrationPetitions).Repeat.Any(); }
public static void FakevTermCode(int count, IRepository<vTermCode> termCodeRepository, List<vTermCode> specificTermCodes) { var termCodes = new List<vTermCode>(); var specificTermCodesCount = 0; if (specificTermCodes != null) { specificTermCodesCount = specificTermCodes.Count; for (int i = 0; i < specificTermCodesCount; i++) { termCodes.Add(specificTermCodes[i]); } } for (int i = 0; i < count; i++) { termCodes.Add(CreateValidEntities.vTermCode(i + specificTermCodesCount + 1)); termCodes[i + specificTermCodesCount].EndDate = DateTime.Now.AddDays((-2 + i)).Date; } var totalCount = termCodes.Count; for (int i = 0; i < totalCount; i++) { termCodes[i].SetIdTo((i + 1).ToString()); //int i1 = i; //repository.OfType<State>() // .Expect(a => a.GetNullableById(i1 + 1)) // .Return(TermCode[i]) // .Repeat // .Any(); } //State is not an Int Id, if I need to fake this, I'll need to pass a different repository //repository.OfType<TermCode>().Expect(a => a.GetNullableById(totalCount + 1)).Return(null).Repeat.Any(); termCodeRepository.Expect(a => a.Queryable).Return(termCodes.AsQueryable()).Repeat.Any(); termCodeRepository.Expect(a => a.GetAll()).Return(termCodes).Repeat.Any(); }
public static void FakeSpecialNeeds(int count, IRepository<SpecialNeed> repository, List<SpecialNeed> specificSpecialNeeds) { var specialNeeds = new List<SpecialNeed>(); var specificSpecialNeedsCount = 0; if (specificSpecialNeeds != null) { specificSpecialNeedsCount = specificSpecialNeeds.Count; for (int i = 0; i < specificSpecialNeedsCount; i++) { specialNeeds.Add(specificSpecialNeeds[i]); } } for (int i = 0; i < count; i++) { specialNeeds.Add(CreateValidEntities.SpecialNeed(i + specificSpecialNeedsCount + 1)); } var totalCount = specialNeeds.Count; for (int i = 0; i < totalCount; i++) { specialNeeds[i].SetIdTo(i + 1); int i1 = i; repository .Expect(a => a.GetNullableById(i1 + 1)) .Return(specialNeeds[i]) .Repeat .Any(); } repository.Expect(a => a.GetNullableById(totalCount + 1)).Return(null).Repeat.Any(); repository.Expect(a => a.Queryable).Return(specialNeeds.AsQueryable()).Repeat.Any(); repository.Expect(a => a.GetAll()).Return(specialNeeds).Repeat.Any(); }
/// <summary> /// Fakes the student. Note: Using more than 20 will not be reliable /// because the Guids will be random /// </summary> /// <param name="count">The count.</param> /// <param name="studentRepository">The student repository.</param> /// <param name="specificStudents">The specific students.</param> /// <param name="studentRepository2">The student repository2.</param> public static void FakeStudent(int count, IRepositoryWithTypedId<Student, Guid> studentRepository, List<Student> specificStudents, IRepository<Student> studentRepository2) { var students = new List<Student>(); var specificStudentsCount = 0; if (specificStudents != null) { specificStudentsCount = specificStudents.Count; for (int i = 0; i < specificStudentsCount; i++) { students.Add(specificStudents[i]); } } for (int i = 0; i < count; i++) { students.Add(CreateValidEntities.Student(i + specificStudentsCount + 1)); } var totalCount = students.Count; for (int i = 0; i < totalCount; i++) { students[i].SetIdTo(SpecificGuid.GetGuid(i+1)); int i1 = i; studentRepository .Expect(a => a.GetNullableById(students[i1].Id)) .Return(students[i]) .Repeat .Any(); } studentRepository.Expect(a => a.GetNullableById(SpecificGuid.GetGuid(totalCount + 1))).Return(null).Repeat.Any(); studentRepository.Expect(a => a.Queryable).Return(students.AsQueryable()).Repeat.Any(); studentRepository.Expect(a => a.GetAll()).Return(students).Repeat.Any(); if(studentRepository2 != null) { studentRepository2.Expect(a => a.Queryable).Return(students.AsQueryable()).Repeat.Any(); studentRepository2.Expect(a => a.GetAll()).Return(students).Repeat.Any(); } }
public new void SetUp() { _customerSettings = new CustomerSettings(); _securitySettings = new SecuritySettings() { EncryptionKey = "273ece6f97dd844d" }; _rewardPointsSettings = new RewardPointsSettings() { Enabled = false, }; _encryptionService = new EncryptionService(_securitySettings); _customerRepo = MockRepository.GenerateMock<IRepository<Customer>>(); var customer1 = new Customer() { Username = "[email protected]", Email = "[email protected]", PasswordFormat = PasswordFormat.Hashed, Active = true }; string saltKey = _encryptionService.CreateSaltKey(5); string password = _encryptionService.CreatePasswordHash("password", saltKey); customer1.PasswordSalt = saltKey; customer1.Password = password; AddCustomerToRegisteredRole(customer1); var customer2 = new Customer() { Username = "[email protected]", Email = "[email protected]", PasswordFormat = PasswordFormat.Clear, Password = "password", Active = true }; AddCustomerToRegisteredRole(customer2); var customer3 = new Customer() { Username = "[email protected]", Email = "[email protected]", PasswordFormat = PasswordFormat.Encrypted, Password = _encryptionService.EncryptText("password"), Active = true }; AddCustomerToRegisteredRole(customer3); var customer4 = new Customer() { Username = "[email protected]", Email = "[email protected]", PasswordFormat = PasswordFormat.Clear, Password = "password", Active = true }; AddCustomerToRegisteredRole(customer4); var customer5 = new Customer() { Username = "[email protected]", Email = "[email protected]", PasswordFormat = PasswordFormat.Clear, Password = "password", Active = true }; _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _customerRepo.Expect(x => x.Table).Return(new List<Customer>() { customer1, customer2, customer3, customer4, customer5 }.AsQueryable()); _customerRoleRepo = MockRepository.GenerateMock<IRepository<CustomerRole>>(); _genericAttributeRepo = MockRepository.GenerateMock<IRepository<GenericAttribute>>(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); _newsLetterSubscriptionService = MockRepository.GenerateMock<INewsLetterSubscriptionService>(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _customerService = new CustomerService(new NopNullCache(), _customerRepo, _customerRoleRepo, _genericAttributeRepo, _genericAttributeService, _eventPublisher, _customerSettings); _customerRegistrationService = new CustomerRegistrationService(_customerService, _encryptionService, _newsLetterSubscriptionService, _localizationService, _rewardPointsSettings, _customerSettings); }
public new void SetUp() { measureDimension1 = new MeasureDimension() { Id = 1, Name = "inch(es)", SystemKeyword = "inches", Ratio = 1M, DisplayOrder = 1, }; measureDimension2 = new MeasureDimension() { Id = 2, Name = "feet", SystemKeyword = "feet", Ratio = 0.08333333M, DisplayOrder = 2, }; measureDimension3 = new MeasureDimension() { Id = 3, Name = "meter(s)", SystemKeyword = "meters", Ratio = 0.0254M, DisplayOrder = 3, }; measureDimension4 = new MeasureDimension() { Id = 4, Name = "millimetre(s)", SystemKeyword = "millimetres", Ratio = 25.4M, DisplayOrder = 4, }; measureWeight1 = new MeasureWeight() { Id = 1, Name = "ounce(s)", SystemKeyword = "ounce", Ratio = 16M, DisplayOrder = 1, }; measureWeight2 = new MeasureWeight() { Id = 2, Name = "lb(s)", SystemKeyword = "lb", Ratio = 1M, DisplayOrder = 2, }; measureWeight3 = new MeasureWeight() { Id = 3, Name = "kg(s)", SystemKeyword = "kg", Ratio = 0.45359237M, DisplayOrder = 3, }; measureWeight4 = new MeasureWeight() { Id = 4, Name = "gram(s)", SystemKeyword = "grams", Ratio = 453.59237M, DisplayOrder = 4, }; _measureDimensionRepository = MockRepository.GenerateMock<IRepository<MeasureDimension>>(); _measureDimensionRepository.Expect(x => x.Table).Return(new List<MeasureDimension>() { measureDimension1, measureDimension2, measureDimension3, measureDimension4 }.AsQueryable()); _measureDimensionRepository.Expect(x => x.GetById(measureDimension1.Id)).Return(measureDimension1); _measureDimensionRepository.Expect(x => x.GetById(measureDimension2.Id)).Return(measureDimension2); _measureDimensionRepository.Expect(x => x.GetById(measureDimension3.Id)).Return(measureDimension3); _measureDimensionRepository.Expect(x => x.GetById(measureDimension4.Id)).Return(measureDimension4); _measureWeightRepository = MockRepository.GenerateMock<IRepository<MeasureWeight>>(); _measureWeightRepository.Expect(x => x.Table).Return(new List<MeasureWeight>() { measureWeight1, measureWeight2, measureWeight3, measureWeight4 }.AsQueryable()); _measureWeightRepository.Expect(x => x.GetById(measureWeight1.Id)).Return(measureWeight1); _measureWeightRepository.Expect(x => x.GetById(measureWeight2.Id)).Return(measureWeight2); _measureWeightRepository.Expect(x => x.GetById(measureWeight3.Id)).Return(measureWeight3); _measureWeightRepository.Expect(x => x.GetById(measureWeight4.Id)).Return(measureWeight4); var cacheManager = new NasNullCache(); _measureSettings = new MeasureSettings(); _measureSettings.BaseDimensionId = measureDimension1.Id; //inch(es) _measureSettings.BaseWeightId = measureWeight2.Id; //lb(s) _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _measureService = new MeasureService(cacheManager, _measureDimensionRepository, _measureWeightRepository, _measureSettings, _eventPublisher); }
public new void SetUp() { currencyUSD = new Currency() { Id = 1, Name = "US Dollar", CurrencyCode = "USD", Rate = 1.2M, DisplayLocale = "en-US", CustomFormatting = "", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyEUR = new Currency() { Id = 2, Name = "Euro", CurrencyCode = "EUR", Rate = 1, DisplayLocale = "", CustomFormatting = "€0.00", Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyRUR = new Currency() { Id = 3, Name = "Russian Rouble", CurrencyCode = "RUB", Rate = 34.5M, DisplayLocale = "ru-RU", CustomFormatting = "", Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; _currencyRepository = MockRepository.GenerateMock<IRepository<Currency>>(); _currencyRepository.Expect(x => x.Table).Return(new List<Currency>() { currencyUSD, currencyEUR, currencyRUR }.AsQueryable()); _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD); _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR); _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR); var cacheManager = new NopNullCache(); _customerService = MockRepository.GenerateMock<ICustomerService>(); _currencySettings = new CurrencySettings(); _currencySettings.PrimaryStoreCurrencyId = currencyUSD.Id; _currencySettings.PrimaryExchangeRateCurrencyId = currencyEUR.Id; _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepository, _customerService, _currencySettings, pluginFinder, _eventPublisher); }
public new void SetUp() { #region Test data //color (dropdownlist) ca1 = new CheckoutAttribute { Id = 1, Name= "Color", TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, }; cav1_1 = new CheckoutAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, CheckoutAttribute = ca1, CheckoutAttributeId = ca1.Id, }; cav1_2 = new CheckoutAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, CheckoutAttribute = ca1, CheckoutAttributeId = ca1.Id, }; ca1.CheckoutAttributeValues.Add(cav1_1); ca1.CheckoutAttributeValues.Add(cav1_2); //custom option (checkboxes) ca2 = new CheckoutAttribute { Id = 2, Name = "Custom option", TextPrompt = "Select custom option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, }; cav2_1 = new CheckoutAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, CheckoutAttribute = ca2, CheckoutAttributeId = ca2.Id, }; cav2_2 = new CheckoutAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, CheckoutAttribute = ca2, CheckoutAttributeId = ca2.Id, }; ca2.CheckoutAttributeValues.Add(cav2_1); ca2.CheckoutAttributeValues.Add(cav2_2); //custom text ca3 = new CheckoutAttribute { Id = 3, Name = "Custom text", TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.MultilineTextbox, DisplayOrder = 3, }; #endregion _checkoutAttributeRepo = MockRepository.GenerateMock<IRepository<CheckoutAttribute>>(); _checkoutAttributeRepo.Expect(x => x.Table).Return(new List<CheckoutAttribute> { ca1, ca2, ca3 }.AsQueryable()); _checkoutAttributeRepo.Expect(x => x.GetById(ca1.Id)).Return(ca1); _checkoutAttributeRepo.Expect(x => x.GetById(ca2.Id)).Return(ca2); _checkoutAttributeRepo.Expect(x => x.GetById(ca3.Id)).Return(ca3); _checkoutAttributeValueRepo = MockRepository.GenerateMock<IRepository<CheckoutAttributeValue>>(); _checkoutAttributeValueRepo.Expect(x => x.Table).Return(new List<CheckoutAttributeValue> { cav1_1, cav1_2, cav2_1, cav2_2 }.AsQueryable()); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_1.Id)).Return(cav1_1); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_2.Id)).Return(cav1_2); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_1.Id)).Return(cav2_1); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_2.Id)).Return(cav2_2); var cacheManager = new NopNullCache(); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _checkoutAttributeService = new CheckoutAttributeService(cacheManager, _checkoutAttributeRepo, _checkoutAttributeValueRepo, _storeMappingService, _eventPublisher); _checkoutAttributeParser = new CheckoutAttributeParser(_checkoutAttributeService); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _taxService = MockRepository.GenerateMock<ITaxService>(); _priceFormatter = MockRepository.GenerateMock<IPriceFormatter>(); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _checkoutAttributeFormatter = new CheckoutAttributeFormatter(_workContext, _checkoutAttributeService, _checkoutAttributeParser, _currencyService, _taxService, _priceFormatter, _downloadService, _webHelper); }
public new void SetUp() { currencyUSD = new Currency() { Id = 1, Name = "US Dollar", CurrencyCode = "USD", Rate = 1.2M, DisplayLocale = "en-US", CustomFormatting = "", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyEUR = new Currency() { Id = 2, Name = "Euro", CurrencyCode = "EUR", Rate = 1, DisplayLocale = "de-DE", CustomFormatting = "€0.00", Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyRUR = new Currency() { Id = 3, Name = "Russian Rouble", CurrencyCode = "RUB", Rate = 34.5M, DisplayLocale = "ru-RU", CustomFormatting = "", Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; _currencyRepository = MockRepository.GenerateMock<IRepository<Currency>>(); _currencyRepository.Expect(x => x.Table).Return(new List<Currency>() { currencyUSD, currencyEUR, currencyRUR }.AsQueryable()); _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD); _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR); _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); _storeContext = MockRepository.GenerateMock<IStoreContext>(); var cacheManager = new NullCache(); _currencySettings = new CurrencySettings(); _storeContext.Expect(x => x.CurrentStore).Return(new Store { Name = "Computer store", Url = "http://www.yourStore.com", Hosts = "yourStore.com,www.yourStore.com", PrimaryStoreCurrency = currencyUSD, PrimaryExchangeRateCurrency = currencyEUR }); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepository, _storeMappingService, _currencySettings, pluginFinder, _eventPublisher, this.ProviderManager, _storeContext); }
public new void SetUp() { #region Test data //color (dropdownlist) pa1 = new ProductAttribute { Id = 1, Name = "Color", }; pva1_1 = new ProductVariantAttribute { Id = 11, ProductVariantId = 1, TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa1.Id }; pvav1_1 = new ProductVariantAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pvav1_2 = new ProductVariantAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pva1_1.ProductVariantAttributeValues.Add(pvav1_1); pva1_1.ProductVariantAttributeValues.Add(pvav1_2); //custom option (checkboxes) pa2 = new ProductAttribute { Id = 2, Name = "Some custom option", }; pva2_1 = new ProductVariantAttribute { Id = 21, ProductVariantId = 1, TextPrompt = "Select at least one option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, ProductAttribute = pa2, ProductAttributeId = pa2.Id }; pvav2_1 = new ProductVariantAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pvav2_2 = new ProductVariantAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pva2_1.ProductVariantAttributeValues.Add(pvav2_1); pva2_1.ProductVariantAttributeValues.Add(pvav2_2); //custom text pa3 = new ProductAttribute { Id = 3, Name = "Custom text", }; pva3_1 = new ProductVariantAttribute { Id = 31, ProductVariantId = 1, TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.TextBox, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa3.Id }; #endregion _productAttributeRepo = MockRepository.GenerateMock<IRepository<ProductAttribute>>(); _productAttributeRepo.Expect(x => x.Table).Return(new List<ProductAttribute>() { pa1, pa2, pa3 }.AsQueryable()); _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1); _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2); _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3); _productVariantAttributeRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttribute>>(); _productVariantAttributeRepo.Expect(x => x.Table).Return(new List<ProductVariantAttribute>() { pva1_1, pva2_1, pva3_1 }.AsQueryable()); _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1); _productVariantAttributeCombinationRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeCombination>>(); _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeCombination>().AsQueryable()); _productVariantAttributeValueRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeValue>>(); _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeValue>() { pvav1_1, pvav1_2, pvav2_1, pvav2_2 }.AsQueryable()); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); var cacheManager = new NasNullCache(); _productAttributeService = new ProductAttributeService(cacheManager, _productAttributeRepo, _productVariantAttributeRepo, _productVariantAttributeCombinationRepo, _productVariantAttributeValueRepo, _eventPublisher); _productAttributeParser = new ProductAttributeParser(_productAttributeService); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}"); _taxService = MockRepository.GenerateMock<ITaxService>(); _priceFormatter = MockRepository.GenerateMock<IPriceFormatter>(); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _productAttributeFormatter = new ProductAttributeFormatter(_workContext, _productAttributeService, _productAttributeParser, _currencyService, _localizationService, _taxService, _priceFormatter, _downloadService, _webHelper); }
public void SetUp() { _solutionBPCalculationRepo = MockRepository.GenerateMock<IRepository<SolutionBPCalculation>>(); var configCurrent = new SolutionBPCalculationConfig { IsCurrent = true }; var config2 = new SolutionBPCalculationConfig { IsCurrent = false }; var entity1 = new SolutionBPCalculation { Id = 1, BPTypeID = 1, CalculationConfigID = 1, Calculation = "Calculation", BPTypeMLL = "BPTypeMLL", SolutionBPCalculationConfig = config2 }; var entity2 = new SolutionBPCalculation { Id = 2, BPTypeID = 1, CalculationConfigID = 1, Calculation = "Current Calculation", BPTypeMLL = "BPTypeMLL", SolutionBPCalculationConfig = configCurrent }; var entity3 = new SolutionBPCalculation { Id = 3, BPTypeID = 2, CalculationConfigID = 2, Calculation = "Calculation", BPTypeMLL = "BPTypeMLL", SolutionBPCalculationConfig = config2 }; var cacheManager = new NopNullCache(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _solutionBPCalculationRepo.Expect(x => x.Table).Return(new List<SolutionBPCalculation> { entity1, entity2, entity3}.AsQueryable()); _solutionBPCalculationService = new SolutionBPCalculationService(cacheManager, _solutionBPCalculationRepo, _eventPublisher); }