public MainWindow() { bool db = false; using (var connection = new OleDbConnection(@"Server = (localdb)\mssqllocaldb; Trusted_Connection = True; ")) { try { connection.Open(); db = true; } catch (Exception e) { } } IRepository repository; if (db) { repository = new DBRepository(); } else { repository = new CSVRepository(); } InitializeComponent(); DataContext = new SamuraiBattleViewModel(repository); }
public void Test1() { CSVRepository repo = new CSVRepository(); var expected = repo.GetPeople(); Assert.NotNull(expected); }
public void TestSetup() { IFileNameManager fileNameManager = new FileNameManager(); IIOManager ioManager = new IOManager(fileNameManager); ICSVRepository csvRepository = new CSVRepository(); csvManager = new CSVManager(csvRepository, ioManager); }
private void ComposeObjects() { //SuperheroRepository repository = new SuperheroRepository(); ISuperheroRepository repository = new CSVRepository(); SuperheroViewModel viewModel = new SuperheroViewModel(repository); Application.Current.MainWindow = new SuperheroesViewerWindow(viewModel); }
public MainWindow() { InitializeComponent(); _repo = new CSVRepository(); CarsGrid.SelectionMode = DataGridSelectionMode.Single; CarsGrid.SelectedItem = null; PathLabelShow(); }
public async System.Threading.Tasks.Task WriteZipsToCSVFile_ShouldWriteToCSVAsync() { CSVRepository csvRepository = new CSVRepository(); string filepath = $@"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName}/StubForms/mockCSV.csv"; //if (File.Exists(filepath)) // File.Delete(filepath); //Will overwrite existing file //Not reusing filestream as implementation handles IO var file = File.Create(filepath); file.Close(); List <ZipFile> records = new List <ZipFile>() { new ZipFile { FilePath = "C:/Camera", Password = "******" }, new ZipFile { FilePath = "C:/Camera/asd", Password = "******" }, new ZipFile { FilePath = "C:/Camera/adasd", Password = "******" }, }; await csvRepository.WriteZipsToCSVFileAsync(filepath, records); List <string[]> csvResult = ReadCSV(filepath); Assert.AreEqual(3, csvResult.Count); for (int i = 0; i < records.Count; i++) { for (int y = 0; y < csvResult.Count; y++) { Assert.AreEqual(records[i].FilePath, csvResult[y][0]); Assert.AreEqual(records[i].Password, csvResult[y][1]); i++; } } if (File.Exists(filepath)) { File.Delete(filepath); } }
public void GetPeople_WithOnlyBadRecord_ReturnsEmptyList() { var repository = new CSVRepository(); repository.FileLoader = new FakeFileLoader("Bad"); var result = repository.GetPeople(); Assert.IsEmpty(result); }
public void GetPeople_WithBadRecords_ReturnsGoodRecords() { var repository = new CSVRepository(); repository.FileLoader = new FakeFileLoader("Mixed"); var result = repository.GetPeople(); Assert.AreEqual(2, result.Count()); }
private void btnCSV_Click(object sender, RoutedEventArgs e) { ClearListBox(); ICustomerRepository csvRepo = new CSVRepository(); var customers = csvRepo.GetCustomers(); foreach (var customer in customers) { lstCustomers.Items.Add(customer); } ShowRepositoryType(csvRepo); }
public CreateEditWindow(CSVRepository repository) { InitializeComponent(); EventsInit(); InitEnums(); _repo = repository; CreateEditButton.Content = "Создать"; _isCreateAction = true; ConditionComboBox.SelectedItem = CarsCondition.Good; BodyTypeCombobox.SelectedItem = BodyTypes.Wagon; }
public void GetTask_WithNoFile_ThrowsFileNotFoundException() { var repository = new CSVRepository(); try { var result = repository.GetPeople(); Assert.Fail(); } catch (FileNotFoundException) { Assert.Pass(); } }
private void CSVFetchButton_Click(object sender, RoutedEventArgs e) { ClearListBox(); IPersonRepository repository = new CSVRepository(); var people = repository.GetPeople(); foreach (var person in people) { PersonListBox.Items.Add(person); } ShowRepositoryType(repository); }
public CreateEditWindow(Car car, CSVRepository repository) { InitializeComponent(); EventsInit(); InitEnums(); _repo = repository; //textbox init TextBoxEditInit(car); //textbox init ConditionComboBox.SelectedItem = car.condition; BodyTypeCombobox.SelectedItem = car.bodyType; _isCreateAction = false; }
//FIELDS //CONSTRUCTORS //METHODS public static IStockPricesRepository GetRepository(string repositoryType) { IStockPricesRepository repository = null; switch (repositoryType) { case "API": repository = new APIRepository(); break; case "CSV": repository = new CSVRepository(); break; default: throw new ArgumentException("Invalid Repository Type Requested"); } return(repository); }
public void AddWorker(string inputString) { CSVRepository repo = new CSVRepository(inputString); workers.Add(new Worker { WorkerId = repo.GetWorkerId(), FirstName = repo.GetWorkerFirstName(), LastName = repo.GetWorkerLastName(), ContractFrom = repo.GetWorkerContractFrom(), ContractUntil = repo.GetWorkerContractUntil(), WorkerContractType = repo.GetWorkerContractType(), WorkerDepartment = GetOrCreateDepartment(repo.GetWorkerDepartmentString()), WorkerPosition = GetOrCreatePosition(repo.GetWorkerPositionString(), _newDepartment) }); Department GetOrCreateDepartment(string DepartmentNameInput) { foreach (Department dep in departments) { if (dep.DepartmentName == DepartmentNameInput) { return(dep); } } _newDepartment = new Department(DepartmentNameInput); departments.Add(_newDepartment); return(_newDepartment); } Position GetOrCreatePosition(string PositionNameInput, Department PositionDepartment) { foreach (Position pos in PositionDepartment.Positions) { if (pos.PositionName == PositionNameInput) { return(pos); } } _newPosition = new Position(PositionNameInput); PositionDepartment.Positions.Add(_newPosition); return(_newPosition); } }
public static ICarRepository GetRepository(string repositoryType) { ICarRepository repository = null; switch (repositoryType) { case "JSON": repository = new JSONRepository(); break; case "CSV": repository = new CSVRepository(); break; default: Console.WriteLine("The Repository you have entered is Invalid! Please enter valid one!"); break; } return(repository); }
public static IPersonRepository GetRepository(string repositoryType) { IPersonRepository repo switch (repositoryType) { case "Service": repo = new ServiceRepository(); break; case "CSV": repo = new CSVRepository(); break; case "SQL": repo = new SQLRepository(); break; default: throw new ArgumentException("Invalid Repository Type"); break; } return repo; }
public static IPersonRepository GetRepository(string repositoryType) { IPersonRepository repo = null; switch (repositoryType) { case "Service": repo = new ServiceRepository(); break; case "CSV": repo = new CSVRepository(); break; case "SQL": repo = new SQLRepository(); break; default: throw new ArgumentException("Invalid Repostiory type."); } return(repo); }
public static IPersonRepository GetRepository(RepositoryType repositoryType) { IPersonRepository repository; switch (repositoryType) { case RepositoryType.CSVRepository: repository = new CSVRepository(); break; case RepositoryType.ServiceRepository: repository = new ServiceRepository(); break; default: throw new ArgumentException("Invalid repository type"); } return(repository); }
public static IPersonRepository GetRepository(string repositoryType) { IPersonRepository repository = null; switch (repositoryType) { case "Service": repository = new ServiceRepository(); break; case "CSV": repository = new CSVRepository(); break; case "SQL": repository = new SQLRepository(); break; default: break; } return(repository); }
public static IPersonRepository GetRepository(RepositoryType type) { IPersonRepository repo = null; switch (type) { case RepositoryType.Service: repo = new ServiceRepository(); break; case RepositoryType.CSV: repo = new CSVRepository(); break; case RepositoryType.SQL: repo = new SQLRepository(); break; default: throw new ArgumentException("Invalid repo type"); } return(repo); }
public static ICustomerRepository GetRepository(string repositoryType) { ICustomerRepository repository; switch (repositoryType) { case "SQL": repository = new SQLRepository(); break; case "XML": repository = new XMLRepository(); break; case "CSV": repository = new CSVRepository(); break; default: throw new ArgumentException("Invalid repository type " + repositoryType); } return(repository); }
public static IPersonReader GetRepository(string repositoryType) { IPersonReader repository = null; switch (repositoryType) { case "Service": repository = new ServiceRepository(); break; case "CSV": repository = new CSVRepository(); break; case "SQL": repository = new SQLRepository(); break; default: throw new ArgumentNullException("Invalid repository"); } return(repository); }
public static IPersonRepository GetRepository(string repositoryType) { IPersonRepository personRepository = null; switch (repositoryType) { case "Service": personRepository = new ServiceRepository(); break; case "CSV": personRepository = new CSVRepository(); break; case "SQL": personRepository = new SQLRepository(); break; default: throw new ArgumentException("Argument not valid"); } return(personRepository); }
public CSVService(string fileName) { this.repository = new CSVRepository(); this.fileName = fileName; }