public void GetAllComponentsFromRepository() { // Arrange ComponentRepository cmprepository = new ComponentRepository(); var testComponents = new List <SadgguruTeaShopUnitTest.Models.Component>(); testComponents.Add(new Component { ComponentId = 1, Name = "cvb", Description = "asc", Price = 12 }); testComponents.Add(new Component { ComponentId = 2, Name = "Sugar", Description = "Crystal Sugar", Price = 77 }); testComponents.Add(new Component { ComponentId = 3, Name = "Tea Powder", Description = "TATA Tea", Price = 46 }); var components = cmprepository.GetAllComponents(); Assert.AreEqual(components.Count, testComponents.Count); }
public UnitOfWork(UndercarriageContext context) { _context = context; Components = new ComponentRepository(_context); Users = new UserRepository(_context); Equipments = new EquipmentRepository(_context); }
public EmbeddedResource GetFile(string path) { if (!path.Contains('/')) { return(null); } var slashIndex = path.IndexOf('/'); var componentId = path.Substring(0, slashIndex); var localPath = path.Substring(slashIndex + "/".Length); foreach (var component in ComponentRepository.GetAll().Where(c => c.Id.Equals(componentId, StringComparison.InvariantCultureIgnoreCase))) { if (component.Scripts.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } if (component.Styles.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } if (component.Resources.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } } return(null); }
public void application_loader_shall_instanciate_all_modules_and_notify_the_splash_progress_accordingly() { ComponentRepository Repository = new ComponentRepository(); Repository.AddComponent <ApplicationLoader>(); Repository.AddComponent <SplashScreenMock>(); Repository.AddComponent <Test1>(); Repository.AddComponent <Test2>(); Repository.AddComponent <Test3>(); using (ComponentContainer ComponentContainer = new ComponentContainer(Repository)) { SplashScreenMock SplashScreen = (SplashScreenMock)ComponentContainer.ResolveInstance <ISplashScreen>();//resolve before because otherwise it is removed after application run and below that a new instance would be created ComponentContainer.ResolveInstance <IApplicationLoader>().Run(); Assert.IsTrue(Test2.RunCalled); Assert.IsTrue(SplashScreen.ShowCalled); Assert.IsTrue(SplashScreen.HideCalled); Assert.That(SplashScreen.StatusTexts, Is.EquivalentTo(new[] { "Status: Test1", "Status: Test2" })); } }
public ActionResult Delete(string id) { var repo = new ComponentRepository(); repo.Delete(new ObjectId(id)); return JsonNet(new {success = true}); }
private void InitializeRepository() { this.componentRepository = new ComponentRepository(); this.componentRepository.AddComponent <ApplicationLoader>(); this.AddComponents(this.componentRepository); }
public void GlobalSetup() { var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); _availableComponents = allComponents.Keys .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); var componentDatabase = new ComponentDatabase(componentLookup); var componentRepository = new ComponentRepository(componentLookup, componentDatabase); var entityFactory = new DefaultEntityFactory(new IdPool(), componentRepository); var poolFactory = new DefaultEntityCollectionFactory(entityFactory); var observableGroupFactory = new DefaultObservableObservableGroupFactory(); _entityCollectionManager = new EntityCollectionManager(poolFactory, observableGroupFactory, componentLookup); _availableComponents = _groupFactory.GetComponentTypes .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); _testGroups = _groupFactory.CreateTestGroups().ToArray(); foreach (var group in _testGroups) { _entityCollectionManager.GetObservableGroup(group); } _defaultEntityCollection = _entityCollectionManager.GetCollection(); }
public bool ExisteItemZerado() { var repository = new ComponentRepository(); bool exist = repository.Stocks.Where(x => x.Quantity < -1).Any(); return(exist); }
private IEnumerable <TComponent> GetAndWaitWebDriverElements() { var elementWaiter = new ComponentWaitService <TDriver, TDriverElement>(); elementWaiter.WaitInternal(_by, new WaitToExistStrategy <TDriver, TDriverElement>()); var nativeElements = _mobileElement == null ? _by.FindAllElements(WrappedDriver) : _by.FindAllElements(_mobileElement); foreach (var nativeElement in nativeElements) { var elementRepository = new ComponentRepository(); var wrappedDriver = ServicesCollection.Current.Resolve <TDriver>(); TDriverElement currentNativeElement; if (wrappedDriver is AndroidDriver <AndroidElement> ) { currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(AndroidElement), wrappedDriver, nativeElement.Id); } else { currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(IOSElement), wrappedDriver, nativeElement.Id); } yield return(elementRepository.CreateComponentThatIsFound <TComponent, TBy, TDriver, TDriverElement>(_by, currentNativeElement)); } }
public void InsertThenUpdate_ShouldReflectChanges() { // Arrange var dummyString = Guid.NewGuid().ToString().Replace("-", ""); var dbModel = new ComponentModel() { Name = dummyString }; // Act var newId = new ComponentRepository(AppState.ConnectionString) .Insert(dbModel); dummyString = Guid.NewGuid().ToString().Replace("-", ""); var dbModel2 = new ComponentRepository(AppState.ConnectionString) .Select(newId); dbModel2.Name = dummyString; new ComponentRepository(AppState.ConnectionString) .Update(dbModel2); var actualValue = new ComponentRepository(AppState.ConnectionString) .Select(newId) .Name; // Assert Assert.AreEqual(dummyString, actualValue); }
public void InsertBulkThenSelectList_ShouldEqualTwo() { // Arrange var expectedValue = 2; var dummyString = Guid.NewGuid().ToString().Replace("-", ""); var listPoco = new List <ComponentModel>() { new ComponentModel() { Name = dummyString }, new ComponentModel() { Name = dummyString } }; // Act new ComponentRepository(AppState.ConnectionString).InsertBulk(listPoco); var actualValue = new ComponentRepository(AppState.ConnectionString) .SelectList() .Where(x => x.Name.Equals(dummyString)) .ToList() .Count; // Assert Assert.AreEqual(expectedValue, actualValue); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Components = new ComponentRepository(_context); Categories = new CategoryRepository(_context); ComponentTypes = new ComponentTypeRepository(_context); }
public ControlPanelController() { repository = new PageRepository(); componentRepository = new ComponentRepository(); templateRepository = new TemplateRepository(); articleRepository = new ArticleRepository(); bp = new BasketPages(); }
public UnitOfWork(EmbeddedStockContext context) { _context = context; Categories = new CategoryRepository(_context); ComponentTypes = new ComponentTypeRepository(_context); Components = new ComponentRepository(_context); CategoryComponentTypes = new CategoryComponentTypeRepository(_context); }
public ComponentRepository GetRepository() { if (_repository == null) { _repository = new ComponentRepository(); } return(_repository); }
public void AddSubcomponents(ComponentRepository componentRepository) { componentRepository.AddComponent <SmartCardUiProvider>(); componentRepository.AddComponent <WpfSmartCardSelectionProvider>(); componentRepository.AddComponent <SmartCardSelection>(); componentRepository.AddComponent <SmartCardSelectionModel>(); componentRepository.AddComponent <SmartCardSelectionView>(); }
public SwtorcraftingService() { swtoreliteAPI = new SwtoreliteAPI(); componentRankRepo = new ComponentRankRepository(); componentTypeRepo = new ComponentTypeRepository(); rarityRepo = new RarityRepository(); itemAttributeRepo = new ItemAttributeRepository(); componentRepo = new ComponentRepository(); }
public void AddSubcomponents(ComponentRepository componentRepository) { componentRepository.AddComponent <PcscSmartCardServiceModule>(); componentRepository.AddComponent <WpfSmartCardUiModule>(); componentRepository.AddComponent <ApduSenderModule>(); #if DEBUG componentRepository.AddComponent <WhileTrue.Modules.ModelInspector.ModelInspectorModule>(); #endif }
public ComponentForm(Form main) { componentID = -1; ComponentRepository = new ComponentRepository(); MainForm = main as MainForm; InitializeComponent(); ProductGrid.AutoGenerateColumns = false; }
public void AddSubcomponents(ComponentRepository componentRepository) { componentRepository.AddComponent <ModelInspector>(); componentRepository.AddComponent <ModelInspectorModel>(); componentRepository.AddComponent <ModelInspectorWindow.ModelInspectorWindow>(); componentRepository.AddComponent <ModelInspectorWindow.ModelInspectorWindowViewProvider>(); componentRepository.AddComponent <ModelInspectorWindowModel>(); }
public void Integration_GetAllProducts_ShouldReturnListOfProductObjects() { var sut = new ComponentRepository(tableClient); var results = sut.GetAllComponents(); Assert.IsNotNull(results); Assert.AreEqual(fakeComponents.Count(), results.Count()); Assert.IsInstanceOfType(results, typeof(List <Component>)); }
public UnitOfWork(string connectionString) { var configBuilder = new DbContextOptionsBuilder <DysonSphereAssemblerContext>().UseSqlServer(connectionString); _context = new DysonSphereAssemblerContext(configBuilder.Options); Recipes = new RecipeRepository(_context); Components = new ComponentRepository(_context); Machines = new MachineRepository(_context); }
public static MvcHtmlString GetComponent(this HtmlHelper helper, string componentName) { ComponentRepository componentRepository = new ComponentRepository(); if (componentRepository.GetComponentByName(componentName) != null) { return(new MvcHtmlString(componentRepository.GetComponentByName(componentName).Content)); } return(new MvcHtmlString("has not contain :(")); }
public void AddSubcomponents(ComponentRepository componentRepository) { ComponentRepository ApduSenderRepository = new ComponentRepository(componentRepository); ApduSenderRepository.AddComponent <ApduSenderPresenter>(); ApduSenderRepository.AddComponent <ApduSenderModel>(); ApduSenderRepository.AddComponent <ApduSenderView>(); componentRepository.AddComponent <ApduSenderProxy>(ApduSenderRepository); }
public int QuantidadeTotalItensEstoque() { var repository = new ComponentRepository(); var qtd = repository.Stocks .Where(x => x.Quantity > 5) .Select(x => x.Quantity) .Aggregate((acc, x) => acc + x); return(qtd); }
public TComponent Create <TComponent, TBy, TDriver, TDriverElement>(TBy by) where TComponent : Component <TDriver, TDriverElement> where TBy : FindStrategy <TDriver, TDriverElement> where TDriver : AppiumDriver <TDriverElement> where TDriverElement : AppiumWebElement { var elementRepository = new ComponentRepository(); return(elementRepository.CreateComponentThatIsFound <TComponent, TBy, TDriver, TDriverElement>(by, null)); }
public UnitOfWork(ComputerSalonContext context) { this.context = context; AttributeRepository = new AttributeRepository(context); TypeRepository = new TypeRepository(context); SystemBlockRepository = new SystemBlockRepository(context); SystemBlockComponentRepository = new SystemBlockComponentRepository(context); ComponentRepository = new ComponentRepository(context); ValueRepository = new ValueRepository(context); }
// lista de components com estoque zerado public List <string> GetItemsOutOfStock() { var repository = new ComponentRepository(); var componentsList = (from stock in repository.Stocks join component in repository.Components on stock.ComponentId equals component.Id where stock.Quantity == 0 select component.Name).ToList(); return(componentsList); }
public void should_corectly_get_matching_entities() { // easier to test with real stuff var componentLookups = new Dictionary <Type, int> { { typeof(TestComponentOne), 0 }, { typeof(TestComponentTwo), 1 }, { typeof(TestComponentThree), 2 } }; var componentLookupType = new ComponentTypeLookup(componentLookups); var componentDatabase = new ComponentDatabase(componentLookupType); var componentRepository = new ComponentRepository(componentLookupType, componentDatabase); var hasOneAndTwo = new Entity(1, componentRepository); hasOneAndTwo.AddComponent <TestComponentOne>(); hasOneAndTwo.AddComponent <TestComponentTwo>(); var hasAllComponents = new Entity(2, componentRepository); hasAllComponents.AddComponent <TestComponentOne>(); hasAllComponents.AddComponent <TestComponentTwo>(); hasAllComponents.AddComponent <TestComponentThree>(); var hasOneAndThree = new Entity(3, componentRepository); hasOneAndThree.AddComponent <TestComponentOne>(); hasOneAndThree.AddComponent <TestComponentThree>(); var entityGroup = new [] { hasOneAndTwo, hasAllComponents, hasOneAndThree }; var matchGroup1 = new Group(typeof(TestComponentOne), typeof(TestComponentTwo)); var matchGroup2 = new Group(null, new [] { typeof(TestComponentOne), typeof(TestComponentTwo) }, new[] { typeof(TestComponentThree) }); var matchGroup3 = new Group(null, new Type[0], new[] { typeof(TestComponentTwo) }); var group1Results1 = entityGroup.MatchingGroup(matchGroup1).ToArray(); Assert.Equal(2, group1Results1.Length); Assert.Contains(hasOneAndTwo, group1Results1); Assert.Contains(hasAllComponents, group1Results1); var group1Results2 = entityGroup.MatchingGroup(matchGroup2).ToArray(); Assert.Equal(1, group1Results2.Length); Assert.Contains(hasOneAndTwo, group1Results2); var group1Results3 = entityGroup.MatchingGroup(matchGroup3).ToArray(); Assert.Equal(1, group1Results3.Length); Assert.Contains(hasOneAndThree, group1Results3); }
public UnitOfWork(BuildingDbContext context, ILoggedInUserService loggedInUserService) { _context = context; Projects = new ProjectRepository(_context); Suppliess = new SuppliesRepository(_context); Buildings = new BuildingRepository(_context); BuildingOuts = new BuildingOutRepository(_context); Components = new ComponentRepository(_context); OutbuildingType = new OutbuildingsTypeRepository(_context); Attachments = new AttachmentRepository(_context); AttachmentContents = new AttachmentContentRepository(_context); _loggedInUserService = loggedInUserService; }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWork"/> class. /// </summary> /// <param name="context">An <see cref="ApplicationDbContext"/>.</param> public UnitOfWork(ApplicationDbContext context /*, IHttpContextAccessor httpContext*/) { _context = context; Positions = new PositionRepository(_context); Components = new ComponentRepository(_context); Members = new MemberRepository(_context); MemberRanks = new MemberRankRepository(_context); MemberGenders = new MemberGenderRepository(_context); MemberRaces = new MemberRaceRepository(_context); MemberDutyStatus = new MemberDutyStatusRepository(_context); MemberContactNumbers = new MemberContactNumberRepository(_context); PhoneNumberTypes = new PhoneNumberTypeRepository(_context); AppStatuses = new AppStatusRepository(_context); RoleTypes = new MemberRoleTypeRepository(_context); }