当前位置: 首页>>代码示例>>C#>>正文


C# IRepository.Expect方法代码示例

本文整理汇总了C#中IRepository.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Expect方法的具体用法?C# IRepository.Expect怎么用?C# IRepository.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.Expect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FakeCeremony

        /// <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();
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:39,代码来源:ControllerRecordFakes.cs

示例2: Setup

 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);
 }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:13,代码来源:SelectBoxPickerServiceTester.cs

示例3: SetUp

        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);
        }
开发者ID:RobHarrisAZ,项目名称:BlindCommerce,代码行数:35,代码来源:LanguageServiceTests.cs

示例4: Setup

		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);
		}
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:33,代码来源:ProductBinderTester.cs

示例5: Setup

        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);
        }
开发者ID:baoit09,项目名称:BPPricingSheet,代码行数:34,代码来源:SolutionFeatureConfigServiceTests.cs

示例6: Setup

        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);
        }
开发者ID:baoit09,项目名称:BPPricingSheet,代码行数:18,代码来源:SolutionFunderServiceTests.cs

示例7: Setup

 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);
 }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:19,代码来源:FertilizerNeededCalculatorTester.cs

示例8: SetUp

 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);
 }
开发者ID:nvolpe,项目名称:raver,代码行数:53,代码来源:CustomerActivityServiceTests.cs

示例9: SetUp

        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);
        }
开发者ID:boatengfrankenstein,项目名称:SmartStoreNET,代码行数:52,代码来源:DiscountServiceTests.cs

示例10: SetUp

        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);
        }
开发者ID:haithemChkel,项目名称:nopCommerce_33,代码行数:49,代码来源:PriceFormatterTests.cs

示例11: Setup

        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);
        }
开发者ID:baoit09,项目名称:BPPricingSheet,代码行数:15,代码来源:SolutionFunderFeatureServiceTests.cs

示例12: Setup

 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);
 }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:15,代码来源:InventoryServiceTester.cs

示例13: Setup

 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);
 }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:18,代码来源:MaterialsCalculatorTester.cs

示例14: SetUp

        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();
        }
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:42,代码来源:OrderControllerTests.cs

示例15: BeforeEachTest

            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);
            }
开发者ID:RitsukoO,项目名称:sampleprojects,代码行数:20,代码来源:SampleServiceTests.cs


注:本文中的IRepository.Expect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。