예제 #1
0
        public void Save()
        {
            IManufacturerRepository iManufacturer = new ManufacturerRepository(this.connectionString);
            int manufacturerId = iManufacturer.Save(Guid.NewGuid().ToString().Substring(0, 6));

            Assert.IsTrue(manufacturerId > 0);
        }
예제 #2
0
        public void Create_Conflict_ShouldReturnConflictStatusCode()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("E6E6BD6F-5A17-40EF-9E57-BFB76005C75E").Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.AddRange(_manufacturers);
                context.SaveChanges();
            }

            var manufacturer = new Manufacturer
            {
                Id      = 3,
                Name    = "Razer",
                Country = "USA",
            };

            using (var context = new ApplicationDbContext(options))
                using (var manufacturersRepository = new ManufacturerRepository(context))
                {
                    var result = manufacturersRepository.Create(manufacturer);

                    Assert.NotNull(result);
                    Assert.NotNull(result.Data);
                    Assert.Equal((int)HttpStatusCode.Conflict, result.StatusCode);
                }
        }
예제 #3
0
 public AdminPanelController()
 {
     _context = new ApplicationDbContext();
     _manufacturerRepository = new ManufacturerRepository(_context);
     _typeRepository         = new TypeRepository(_context);
     _goodRepository         = new GoodRepository(_context);
 }
 public void OnGet(string vendor)
 {
     furnitureRepository = new FurnitureRepository(QueryMode.ByVendorCode, vendor);
     furnitureRepository.Initialize();
     Furniture = furnitureRepository.Items.FirstOrDefault();
     //
     Furniture.CategoryID     = Furniture.Category.ID;
     Furniture.ManufacturerID = Furniture.Manufacturer.ID;
     Furniture.CollectionID   = Furniture.Collection.ID;
     //
     CollectionRepository = new CollectionRepository();
     CollectionRepository.Initialize();
     //
     ManufacturerRepository = new ManufacturerRepository();
     ManufacturerRepository.Initialize();
     //
     CategoryRepository = new CategoryRepository();
     CategoryRepository.Initialize();
     //
     ColorRepository = new ColorRepository();
     ColorRepository.Initialize();
     //
     MaterialRepository = new MaterialRepository();
     MaterialRepository.Initialize();
 }
예제 #5
0
        public void OnGet()
        {
            ManufacturerRepository manufacturerRepository = new ManufacturerRepository();

            manufacturerRepository.Initialize();
            Manufacturers = manufacturerRepository.Items.OrderBy(i => i.ID).ToList();
        }
예제 #6
0
        public async Task Manufacturer_Repository_Should_Remove_Manufacturer_Async()
        {
            // Arrange
            var context        = TestSetUpHelper.CreateDbContext();
            var repository     = new ManufacturerRepository(context);
            var expectedEntity = new Manufacturer()
            {
                Id   = 4,
                Name = "TestName",
            };

            await repository.AddAsync(expectedEntity);

            await context.SaveChangesAsync();

            // Act
            await repository.RemoveAsync(expectedEntity.Id);

            await context.SaveChangesAsync();

            var actualEntity = await repository.GetByIdAsync(expectedEntity.Id);

            // Assert
            Assert.Null(actualEntity);
        }
예제 #7
0
        private void SetUpManufacturerRepository(CoreAngularDemoDBContext context)
        {
            var manufacturerRepository = new ManufacturerRepository(context);

            _unitOfWork.Setup(u => u.SaveAsync()).Returns(() => context.SaveChangesAsync());
            _unitOfWork.Setup(u => u.ManufacturerRepository).Returns(() => manufacturerRepository);
        }
예제 #8
0
        public void SaveManufacturer_UpdateExistingEntity_ShouldReturnTrue()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("74072F25-F283-4B11-AC92-AE27096F79A7").Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.AddRange(_manufacturers);
                context.SaveChanges();
            }

            var manufacturer = new Manufacturer
            {
                Id      = 3,
                Name    = "Razer",
                Country = "USA",
            };

            using (var context = new ApplicationDbContext(options))
                using (var manufacturersRepository = new ManufacturerRepository(context))
                {
                    var result = manufacturersRepository.SaveManufacturer(manufacturer);

                    Assert.True(result);
                    Assert.Equal(3, manufacturersRepository.Manufacturers.Count());

                    var modified = manufacturersRepository.Manufacturers
                                   .FirstOrDefault(c => c.Id == manufacturer.Id);
                    Assert.NotNull(modified);
                    Assert.Equal(manufacturer.Id, modified.Id);
                    Assert.Equal(manufacturer.Name, modified.Name);
                    Assert.Equal(manufacturer.Country, modified.Country);
                }
        }
예제 #9
0
        public void SaveManufacturer_EntityIdIsGreaterThan0AndDoesNotExistInRepo_ShouldReturnFalse()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("E09F073F-DF5D-48C4-964A-517A56034250").Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.AddRange(_manufacturers);
                context.SaveChanges();
            }

            var manufacturer = new Manufacturer
            {
                Id      = 5,
                Name    = "Razer",
                Country = "USA",
            };

            using (var context = new ApplicationDbContext(options))
                using (var manufacturersRepository = new ManufacturerRepository(context))
                {
                    var result = manufacturersRepository.SaveManufacturer(manufacturer);

                    Assert.False(result);
                    Assert.Equal(3, manufacturersRepository.Manufacturers.Count());
                }
        }
예제 #10
0
 public UnitOfWork(DataContext dataContext)
 {
     _dataContext               = dataContext;
     CaseRepository             = new CaseRepository(_dataContext);
     ChipsetRepository          = new ChipsetRepository(_dataContext);
     CoreSeriesRepository       = new CoreSeriesRepository(_dataContext);
     CoreSpeedRepository        = new CoreSpeedRepository(_dataContext);
     CPURepository              = new CPURepository(_dataContext);
     CPUCoolerRepository        = new CPUCoolerRepository(_dataContext);
     EfficiencyRatingRepository = new EfficiencyRatingRepository(_dataContext);
     FormFactorRepository       = new FormFactorRepository(_dataContext);
     InterfaceRepository        = new InterfaceRepository(_dataContext);
     ManufacturerRepository     = new ManufacturerRepository(_dataContext);
     MemorySpeedRepository      = new MemorySpeedRepository(_dataContext);
     MemoryTypeRepository       = new MemoryTypeRepository(_dataContext);
     ModuleRepository           = new ModuleRepository(_dataContext);
     MotherboardRepository      = new MotherboardRepository(_dataContext);
     NumbersRepository          = new NumbersRepository(_dataContext);
     PowerSupplyRepository      = new PowerSupplyRepository(_dataContext);
     ProtocolRepository         = new ProtocolRepository(_dataContext);
     RAMRepository              = new RAMRepository(_dataContext);
     SocketRepository           = new SocketRepository(_dataContext);
     StorageRepository          = new StorageRepository(_dataContext);
     StorageTypeRepository      = new StorageTypeRepository(_dataContext);
     VideoCardRepository        = new VideoCardRepository(_dataContext);
     WirelessAdapterRepository  = new WirelessAdapterRepository(_dataContext);
 }
예제 #11
0
        public void SaveManufacturer_EntityIdIsSmallerThan0_ShouldReturnFalse()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("61DCFC11-0727-47D6-8FBA-E5FB567104B9").Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.AddRange(_manufacturers);
                context.SaveChanges();
            }

            var manufacturer = new Manufacturer
            {
                Id      = -1,
                Name    = "Razer",
                Country = "USA",
            };

            using (var context = new ApplicationDbContext(options))
                using (var manufacturersRepository = new ManufacturerRepository(context))
                {
                    var result = manufacturersRepository.SaveManufacturer(manufacturer);

                    Assert.False(result);
                    Assert.Equal(3, manufacturersRepository.Manufacturers.Count());
                }
        }
예제 #12
0
        public async Task Manufacturer_Repository_Should_Update_Manufacturer()
        {
            // Arrange
            var context         = TestSetUpHelper.CreateDbContext();
            var repository      = new ManufacturerRepository(context);
            var oldManufacturer = new Manufacturer()
            {
                Id   = 4,
                Name = "TestName",
            };

            var newManufacturer = new Manufacturer()
            {
                Id   = 4,
                Name = "NewTestName",
            };

            await repository.AddAsync(oldManufacturer);

            await context.SaveChangesAsync();

            // Act
            oldManufacturer.Name = newManufacturer.Name;
            repository.Update(oldManufacturer);
            await context.SaveChangesAsync();

            // Assert
            Assert.Equal(newManufacturer.Name, oldManufacturer.Name);
        }
예제 #13
0
 public Manufacturer GetManufacturer(string url)
 {
     List<QueryParameter> parameters = new List<QueryParameter>();
     parameters.Add(new QueryParameter("url", url));
     List<Manufacturer> manufacturers = new ManufacturerRepository().GetByParameter("getByUrl", parameters);
     return manufacturers.Count > 0 ? manufacturers[0] : null;
 }
예제 #14
0
 public int Save(BE.Manufacturer manufacturer)
 {
     ManufacturerRepository repository = new ManufacturerRepository();
     if(manufacturer.ID > 0)
         return repository.Update(manufacturer);
     else
         return repository.Insert(manufacturer);
 }
 public StockInformationRepository()
 {
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
예제 #16
0
 public async Task <IReadOnlyCollection <ReadManufacturerDto> > ManufacturerPaginationAsync(int pageNumber,
                                                                                            int itemsCount,
                                                                                            CancellationToken token) =>
 Mapper.Map <IEnumerable <Manufacturer>, IReadOnlyCollection <ReadManufacturerDto> >(
     await ManufacturerRepository.FetchAsync(
         itemsCount,
         itemsCount * (pageNumber - 1),
         token));
예제 #17
0
        public async Task <IReadOnlyCollection <ReadModelDto> > GetManufacturerModelsAsync(int id, CancellationToken token)
        {
            var manufacturer = await ManufacturerRepository.FindByIdAsync(id, token);

            var models = Mapper.Map <IEnumerable <Model>, IReadOnlyCollection <ReadModelDto> >(manufacturer.Models);

            return(models);
        }
예제 #18
0
 public ecvUnitOfWork(ecvDBContext context)
 {
     _context               = context;
     categoryRepository     = new CategoryRepository(_context);
     productRepository      = new ProductRepository(_context);
     productTypeRepository  = new ProductTypeRepository(_context);
     manufacturerRepository = new ManufacturerRepository(_context);
     vendorRepository       = new VendorRepository(_context);
 }
예제 #19
0
        public ProductDboTest()
        {
            repository             = new ProductRepository(DbContextFactory);
            manufacturerRepository = new ManufacturerRepository(DbContextFactory);
            userRepository         = new UserRepository(DbContextFactory);
            categoryRepository     = new CategoryRepository(DbContextFactory);

            dataService = new ProductDataService(repository, UnitOfWork);
        }
예제 #20
0
        public ProductDboTest()
        {
            repository = new ProductRepository(DbContextFactory);
            manufacturerRepository = new ManufacturerRepository(DbContextFactory);
            userRepository = new UserRepository(DbContextFactory);
            categoryRepository = new CategoryRepository(DbContextFactory);

            dataService  = new ProductDataService(repository, UnitOfWork);
        }
        public void SaveAndGet()
        {
            IManufacturerRepository iManufacturer = new ManufacturerRepository(this.connectionString);
            string name = Guid.NewGuid().ToString().Substring(0, 6);

            int manufacturerSavedId = iManufacturer.Save(name);
            int? manufacturerGetId = iManufacturer.Find(name);

            Assert.IsNotNull(manufacturerGetId);
            Assert.IsTrue(manufacturerSavedId == manufacturerGetId.Value);
        }
예제 #22
0
        public async Task TestManufactuerRepo_Exists()
        {
            //Arrange
            ManufacturerRepository TestRepo = CreateManufacturerTestRepo("ManufacturerExists");

            //Act
            var result = await TestRepo.Exist(_ManufacturerNumber - 1);  //Subtract one since it starts at 0

            //Assert
            Assert.IsTrue(result);
        }
예제 #23
0
        public void TestManufacturerRepo_GetAll()
        {
            //Arrange
            ManufacturerRepository TestRepo = CreateManufacturerTestRepo("ManufacturerGetAll");

            //Act
            var result = TestRepo.GetAll();

            //Assert
            Assert.IsTrue(result.Count() == _ManufacturerNumber);
        }
예제 #24
0
 public void SetValues()
 {
     ManufacturerComboBox.ItemsSource = ManufacturerRepository.GetAll();
     CategorieComboBox.ItemsSource    = CategorieRepository.GetAll();
     ManufacturerComboBox.Text        = Product.Manufacturer.name;
     CategorieComboBox.Text           = Product.Categorie.name;
     NameTextBox.Text  = Product.name;
     PriceTextBox.Text = Product.price.ToString();
     ManufacturedDatePiker.SelectedDate = Product.manufacturedDate;
     ImportDatePiker.SelectedDate       = Product.importDate;
 }
예제 #25
0
        public void SaveAndGet()
        {
            IManufacturerRepository iManufacturer = new ManufacturerRepository(this.connectionString);
            string name = Guid.NewGuid().ToString().Substring(0, 6);

            int manufacturerSavedId = iManufacturer.Save(name);
            int?manufacturerGetId   = iManufacturer.Find(name);

            Assert.IsNotNull(manufacturerGetId);
            Assert.IsTrue(manufacturerSavedId == manufacturerGetId.Value);
        }
예제 #26
0
 public ManufacturerFacade(
     ProductRepository productRepository,
     ManufacturerRepository manufacturerRepository,
     ProductFacade productFacade,
     IMapper mapper)
 {
     this.manufacturerRepository = manufacturerRepository;
     this.mapper            = mapper;
     this.productFacade     = productFacade;
     this.productRepository = productRepository;
 }
 public void OnGet()
 {
     CollectionRepository = new CollectionRepository();
     CollectionRepository.Initialize();
     //
     ManufacturerRepository = new ManufacturerRepository();
     ManufacturerRepository.Initialize();
     //
     CategoryRepository = new CategoryRepository();
     CategoryRepository.Initialize();
 }
        public void Get_Fail_ReturnNull()
        {
            // Arrange
            var repository = new ManufacturerRepository();

            // Act
            var result = repository.Get(111_111_111);

            // Assert
            Assert.IsNull(result);
        }
        public void GetManufacturers_Success_ReturnEntities()
        {
            // Arrange
            var repository = new ManufacturerRepository();

            // Act
            var result = repository.GetManufacturers();

            // Assert
            Assert.IsInstanceOf <IEnumerable <Manufacturer> >(result);
        }
예제 #30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Set up MVC controllers
            services.AddMvc();
            services.AddControllers();

            // Since we don't have a DB to connect to, hydrate model repositories here instead
            ProductRepository.hydrate();
            ManufacturerRepository.hydrate();
            HolidayRepository.hydrate();
        }
예제 #31
0
        public MenuGridViewModel(IEventAggregator ea, IUnityContainer container)
        {
            CommandFindText    = new DelegateCommand(FindText, CanFindText);
            CommandApplySearch = new DelegateCommand(ApplySearch, CanApplySearch);
            CommandViewAll     = new DelegateCommand(ViewAll, CanViewAll);

            _ea = ea;
            _ea.GetEvent <CategorySelectionChange>().Subscribe(ShowCategoryName);

            manufacturerRepository = container.Resolve <ManufacturerRepository>();
        }
 public RequestRepository()
 {
     _clientRepository = new ClientRepository();
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _modeService = new ModeService();
     _paymentTermService = new PaymentTermRepository();
     _orderStatusService = new OrderStatusService();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
        public void Create_Success_ReturnEntity()
        {
            // Arrange
            var repository = new ManufacturerRepository();
            var input      = GenerateInput();

            // Act
            var result = repository.Create(input);

            // Assert
            Assert.That(CompareProperties(input, result));
        }
        public void Get_Success_ReturnEntity()
        {
            // Arrange
            var repository = new ManufacturerRepository();
            var input      = repository.Create(GenerateInput());

            // Act
            var result = repository.Get(input.Id);

            // Assert
            Assert.IsInstanceOf <Manufacturer>(result);
        }
        public void Update_Success_ReturnFalse()
        {
            // Arrange
            var repository = new ManufacturerRepository();
            var input      = GenerateInput(generateId: true);

            // Act
            var result = repository.Update(input);

            // Assert
            Assert.IsFalse(result);
        }
예제 #36
0
 public UnitOfWork(FuzionDbContext ctx)
 {
     _ctx              = ctx;
     Devices           = new DeviceRepository(_ctx);
     DeviceTypes       = new DeviceTypeRepository(_ctx);
     Manufacturers     = new ManufacturerRepository(_ctx);
     Models            = new ModelRepository(_ctx);
     Notes             = new NoteRepository(_ctx);
     OS                = new OSRepository(_ctx);
     Purposes          = new PurposeRepository(_ctx);
     AssignmentHistory = new AssignmentRepository(_ctx);
 }
예제 #37
0
 public ContactService(RequestContext c,
                       AddressRepository addresses,
                       PriceGroupRepository pricegroups,
                       MailingListRepository mailingLists,
                       VendorRepository vendors,
                       ManufacturerRepository manufacturers,
                       AffiliateRepository affiliates,
                       AffiliateReferralRepository affiliateReferrals)
 {
     context = c;
     Addresses = addresses;
     PriceGroups = pricegroups;
     this.MailingLists = mailingLists;
     this.Vendors = vendors;
     this.Manufacturers = manufacturers;
     this.Affiliates = affiliates;
     this.AffiliateReferrals = affiliateReferrals;
 }
        public Approval()
        {
            _requestService = new RequestRepository();
            _stockInformationRepository = new StockInformationRepository();
            _forcastingRepository = new ForcastingRepository();
            _activityRepository = new ActivityRepository();
            _manufacturerRepository = new ManufacturerRepository();
            _physicalRepository = new PhysicalStoreRepository();
            _consumptionRepository = new ConsumptionSettingRespository();
            InitializeComponent();

            //Edit Valued Changed Listener
            lkManufacturer.EditValueChanged += ColumnLookup_EditValueChanged;
            lkActivity.EditValueChanged += ColumnLookup_EditValueChanged;
            lkExpiryPreference.EditValueChanged += ColumnLookup_EditValueChanged;
            lkPhysicalStorePreference.EditValueChanged += ColumnLookup_EditValueChanged;

            gridOrderDetailView.CellMerge += gridViewOrderDetailsForApproval_CellMerge;
            gridOrderDetailView.ShowingEditor += gridViewOrderDetailsForApproval_ShowingEditor;
        }
 public void Save()
 {
     IManufacturerRepository iManufacturer = new ManufacturerRepository(this.connectionString);
     int manufacturerId = iManufacturer.Save(Guid.NewGuid().ToString().Substring(0, 6));
     Assert.IsTrue(manufacturerId > 0);
 }
예제 #40
0
 public ManufacturerDboTest()
 {
     repository = new ManufacturerRepository(DbContextFactory);
     dataService = new ManufacturerDataService(repository, UnitOfWork);
 }