/// <summary> /// Creates a mockup for the data provider which can access data in the food waste repository. /// </summary> /// <returns>Mockup for the data provider which can access data in the food waste repository.</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(FoodItemProxy foodItemProxy = null, FoodGroupProxy foodGroupProxy = null) { IFoodWasteDataProvider foodWasteDataProvider = MockRepository.GenerateMock <IFoodWasteDataProvider>(); foodWasteDataProvider.Stub(m => m.Create(Arg <IFoodItemProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(foodItemProxy ?? BuildFoodItemProxy()) .Repeat.Any(); foodWasteDataProvider.Stub(m => m.Create(Arg <IFoodGroupProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(foodGroupProxy ?? BuildFoodGroupProxy()) .Repeat.Any(); return(foodWasteDataProvider); }
/// <summary> /// Creates an instance of a data provider which should be used for unit testing. /// </summary> /// <returns>Instance of a data provider which should be used for unit testing</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(HouseholdProxy householdProxy = null, StorageTypeProxy storageTypeProxy = null) { IFoodWasteDataProvider dataProviderMock = MockRepository.GenerateMock <IFoodWasteDataProvider>(); dataProviderMock.Stub(m => m.Create(Arg <IHouseholdProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(householdProxy ?? BuildHouseholdProxy()) .Repeat.Any(); dataProviderMock.Stub(m => m.Create(Arg <IStorageTypeProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(storageTypeProxy ?? BuildStorageTypeProxy()) .Repeat.Any(); return(dataProviderMock); }
/// <summary> /// Creates a mockup for the data provider which can access data in the food waste repository. /// </summary> /// <returns>Mockup for the data provider which can access data in the food waste repository.</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(HouseholdMemberProxy householdMemberProxy = null, HouseholdProxy householdProxy = null) { IFoodWasteDataProvider foodWasteDataProvider = MockRepository.GenerateMock <IFoodWasteDataProvider>(); foodWasteDataProvider.Stub(m => m.Create(Arg <IHouseholdMemberProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(householdMemberProxy ?? BuildHouseholdMemberProxy()) .Repeat.Any(); foodWasteDataProvider.Stub(m => m.Create(Arg <IHouseholdProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(householdProxy ?? BuildHouseholdProxy()) .Repeat.Any(); return(foodWasteDataProvider); }
/// <summary> /// Creates an instance of a data provider which should be used for unit testing. /// </summary> /// <returns>Instance of a data provider which should be used for unit testing</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(IEnumerable <TranslationProxy> translationProxyCollection = null) { IFoodWasteDataProvider dataProviderMock = MockRepository.GenerateMock <IFoodWasteDataProvider>(); dataProviderMock.Stub(m => m.Clone()) .Return(dataProviderMock) .Repeat.Any(); dataProviderMock.Stub(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Is.Anything)) .Return(translationProxyCollection ?? _fixture.CreateMany <TranslationProxy>().ToList()) .Repeat.Any(); return(dataProviderMock); }
/// <summary> /// Creates a mockup for the data provider which can access data in the food waste repository. /// </summary> /// <returns>Mockup for the data provider which can access data in the food waste repository.</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(IEnumerable <TranslationProxy> translationProxyCollection = null) { IFoodWasteDataProvider foodWasteDataProvider = MockRepository.GenerateMock <IFoodWasteDataProvider>(); foodWasteDataProvider.Stub(m => m.Clone()) .Return(foodWasteDataProvider) .Repeat.Any(); foodWasteDataProvider.Stub(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Is.Anything)) .Return(translationProxyCollection ?? BuildTranslationProxyCollection(Guid.NewGuid())) .Repeat.Any(); return(foodWasteDataProvider); }
/// <summary> /// Creates an instance of the <see cref="HouseholdDataRepository"/> for unit testing. /// </summary> /// <returns>Instance of the <see cref="HouseholdDataRepository"/> for unit testing.</returns> private IHouseholdDataRepository CreateSut(IEnumerable <HouseholdMemberProxy> householdMemberProxyCollection = null, Exception exception = null) { if (exception == null) { _foodWasteDataProviderMock.Stub(m => m.GetCollection <HouseholdMemberProxy>(Arg <MySqlCommand> .Is.Anything)) .Return(householdMemberProxyCollection ?? new List <HouseholdMemberProxy>(0)) .Repeat.Any(); } else { _foodWasteDataProviderMock.Stub(m => m.GetCollection <HouseholdMemberProxy>(Arg <MySqlCommand> .Is.Anything)) .Throw(exception) .Repeat.Any(); } return(new HouseholdDataRepository(_foodWasteDataProviderMock, _foodWasteObjectMapperMock)); }
/// <summary> /// Creates a mockup for the data provider which can access data in the food waste repository. /// </summary> /// <returns>Mockup for the data provider which can access data in the food waste repository.</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(ITranslationInfoProxy translationInfoProxy = null) { IFoodWasteDataProvider foodWasteDataProviderMock = MockRepository.GenerateMock <IFoodWasteDataProvider>(); foodWasteDataProviderMock.Stub(m => m.Create(Arg <ITranslationInfoProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything)) .Return(translationInfoProxy ?? BuildTranslationInfoProxy(Guid.NewGuid())) .Repeat.Any(); return(foodWasteDataProviderMock); }
/// <summary> /// Creates a mockup for the data provider which can access data in the food waste repository. /// </summary> /// <returns>Mockup for the data provider which can access data in the food waste repository.</returns> private IFoodWasteDataProvider CreateFoodWasteDataProvider(IEnumerable <TranslationProxy> translationProxyCollection = null) { IFoodWasteDataProvider foodWasteDataProvider = MockRepository.GenerateMock <IFoodWasteDataProvider>(); foodWasteDataProvider.Stub(m => m.Clone()) .Return(foodWasteDataProvider) .Repeat.Any(); foodWasteDataProvider.Stub(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Is.Anything)) .WhenCalled(e => { if (translationProxyCollection == null) { e.ReturnValue = BuildTranslationProxyCollection(Guid.NewGuid()); return; } Guid translationOfIdentifier = new Guid((string)((MySqlCommand)e.Arguments.ElementAt(0)).Parameters["@ofIdentifier"].Value); e.ReturnValue = translationProxyCollection.Where(m => m.TranslationOfIdentifier == translationOfIdentifier).ToList(); }) .Return(null) .Repeat.Any(); return(foodWasteDataProvider); }