public ProofOfConceptController() { _repo = new ExtendedRepository <Accounts>(new Helpers.Configurations.IBConfiguration() { Connection = new Helpers.Configurations.Connections(System.Configuration.ConfigurationManager.ConnectionStrings["SysConSQL"].ConnectionString), DbType = Helpers.Enums.DataBaseType.MSSql }, "Accounts"); }
private void OnGetRepositoriesCompleted(IList <ExtendedRepository> repositories, Exception exception) { if (null == repositories || repositories.Count == 0) { Progress = WorkerProgress.Idle; return; } foreach (ExtendedRepository repo in repositories) { _repositoriesToCheck.Add(repo); } if (_workSequential) { if (_repositoriesToCheck.Count > 0) { ExtendedRepository firstRepo = _repositoriesToCheck[0]; _dataService.BeginGetIncomingChanges(firstRepo, OnGetIncomingChangesCompleted); } } else { if (_repositoriesToCheck.Count > 0) { foreach (ExtendedRepository repo in _repositoriesToCheck) { _dataService.BeginGetIncomingChanges(repo, OnGetIncomingChangesCompleted); } } } }
public void GetFilteredElements_SpecificKOrder_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act target.GetFilteredElements <SubEntity>(e => e.Id == 1); }
public void BeginGetRepositories(Action<IList<ExtendedRepository>, Exception> callback) { List<ExtendedRepository> repositories = new List<ExtendedRepository>(); ExtendedRepository repo = new ExtendedRepository("DesignTimeRepoType", "DesignTimeRepoPath"); repo.Name = "DesignTimeRepo"; repositories.Add(repo); callback(repositories, null); }
public void BeginGetIncomingChanges(ExtendedRepository repository, Action<ExtendedRepository, Exception> callback) { repository.IncomingChangesets = new ObservableCollection<ExtendedChangeset>(); ExtendedChangeset changeset = new ExtendedChangeset("DesignTimeChangesetBranch", "DesignTimeChangesetRevision", "DesignTimeChangesetAuthorEmail", DateTime.Now, "DesignTimeChangesetAuthorName", "DesignTimeChangesetCommitMessage"); //changeset.Gravatar repository.IncomingChangesets.Add(changeset); callback(repository, null); }
public void GetFilteredElements_SpecificKOrderFullSignature_NullFilterThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act target.GetFilteredElements <int>(null, 1, 1, t => t.Id, true); }
public void GetFilteredElements_SpecificKFilterAndSOrder_ORderNullThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act target.GetFilteredElements <SubEntity, int>(t => t.Id == 3, null, false); }
public void GetBySpecWithSubType_NullSpecThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act IEnumerable <Entity> result = target.GetBySpec <SubEntity>((ISpecification <SubEntity>)null); }
public void GetFilteredElements_FilterNullThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act target.GetFilteredElements(null); }
public virtual void Repository_ApplyChangesWithNullCollectionThrowNewArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); //Act ExtendedRepository <TEntity> repository = new ExtendedRepository <TEntity>(unitOfWork, traceManager); repository.Modify((List <TEntity>)null); }
public void GetPagedElementsSubType_InvalidOrderExpressionArgumentException_Test() { IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <SubEntity> target = new ExtendedRepository <SubEntity>(unitOfWork, traceManager); int pageIndex = 1; int pageCount = 1; target.GetPagedElements <SubEntity, int>(pageIndex, pageCount, null, false); }
public void BeginGetIncomingChanges(ExtendedRepository repository, Action <ExtendedRepository, Exception> callback) { repository.IncomingChangesets = new ObservableCollection <ExtendedChangeset>(); ExtendedChangeset changeset = new ExtendedChangeset("DesignTimeChangesetBranch", "DesignTimeChangesetRevision", "DesignTimeChangesetAuthorEmail", DateTime.Now, "DesignTimeChangesetAuthorName", "DesignTimeChangesetCommitMessage"); //changeset.Gravatar repository.IncomingChangesets.Add(changeset); callback(repository, null); }
public void BeginGetRepositories(Action <IList <ExtendedRepository>, Exception> callback) { List <ExtendedRepository> repositories = new List <ExtendedRepository>(); ExtendedRepository repo = new ExtendedRepository("DesignTimeRepoType", "DesignTimeRepoPath"); repo.Name = "DesignTimeRepo"; repositories.Add(repo); callback(repositories, null); }
public void Add_NullItemThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); Entity entity = null; //Act target.Add(entity); }
public void ApplyChanges_NullEntityCollectionThrowNewArgumentNullException_Test() { //Arrange IQueryableUnitOfWork actual = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); //Act ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(actual, traceManager); //Assert target.Modify((Collection <Entity>)null); }
public void GetBySpec_NullSpecThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); ISpecification <Entity> spec = new DirectSpecification <Entity>(t => t.Id == 1); //Act target.GetBySpec((ISpecification <Entity>)null); }
public void Attach_NullItem_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); Entity entity = null; //Act target.RegisterItem(entity); }
public void ApplyChanges_Test() { //Arrange IQueryableUnitOfWork actual = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); //Act ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(actual, traceManager); Entity item = target.GetAll().First(); //Assert target.Modify(item); }
public virtual void Repository_ApplyChangesInCollection_Test() { //Arrange IQueryableUnitOfWork unitOfWork = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); //Act ExtendedRepository <TEntity> repository = new ExtendedRepository <TEntity>(unitOfWork, traceManager); List <TEntity> items = new List <TEntity>(); items.Add(new TEntity()); repository.Modify(items); }
public void GetFilteredAndOrderedAndPagedElements_InvalidPageCountThrowArgumentException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); int pageIndex = 0; int pageCount = 0; //Act IEnumerable <Entity> result = target.GetFilteredElements <int>(e => e.Id == 1, pageIndex, pageCount, null, false); }
public void GetBySpec_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); ISpecification <Entity> spec = new DirectSpecification <Entity>(t => t.Id == 1); //Act IEnumerable <Entity> result = target.GetBySpec(spec); //Assert Assert.IsTrue(result.Count() == 1); }
public void GetFilteredAndOrderedElements_InvalidOrderByExpressionThrowArgumentNullException_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act IEnumerable <Entity> result = target.GetFilteredElements <int>(e => e.Id == 1, null, false); //Assert Assert.IsTrue(result != null); Assert.IsTrue(result.Count() == 1); }
public void GetAll_ForSubtypes_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act IEnumerable <SubEntity> result = target.GetAll <SubEntity>(); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Count() == 1); }
public void GetFiltered_WithAscendingOrderedAndPagedElements_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); int pageIndex = 0; int pageCount = 1; //Act IEnumerable <Entity> result = target.GetFilteredElements <int>(e => e.Id == 1, pageIndex, pageCount, e => e.Id, true); //Assert Assert.IsTrue(result != null); Assert.IsTrue(result.Count() == 1); }
/// <summary> ///A test for Container ///</summary> public void unitOfWorkTestHelper <T>() where T : class, IObjectWithChangeTracker, new() { //Arrange IQueryableUnitOfWork actual = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); //Act ExtendedRepository <T> target = new ExtendedRepository <T>(actual, traceManager); //Assert IUnitOfWork expected; expected = target.UnitOfWork as IUnitOfWork; Assert.AreEqual(expected, actual); }
public bool SetRepositoryType(ref ExtendedRepository repository) { bool result = false; foreach (IPlugin plugin in Plugins.Values) { if (plugin.VerifyRepository(repository.Path)) { repository.Type = plugin.RepositoryType; repository.PluginIcon = plugin.PluginIcon; result = true; break; } } return(result); }
public void GetPagedElements_AscendingOrder_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); int pageIndex = 0; int pageCount = 1; //Act IEnumerable <Entity> result = target.GetPagedElements(pageIndex, pageCount, e => e.Id > 0, true); //Assert Assert.IsNotNull(result); Assert.AreEqual(result.Count(), pageCount); }
public bool SetRepositoryType(ref ExtendedRepository repository) { bool result = false; foreach (IPlugin plugin in Plugins.Values) { if (plugin.VerifyRepository(repository.Path)) { repository.Type = plugin.RepositoryType; repository.PluginIcon = plugin.PluginIcon; result = true; break; } } return result; }
internal static ExtendedRepository GetExtendedRepository(Repository repository) { ExtendedRepository result = new ExtendedRepository(repository.Type, repository.Path); result.Name = repository.Name; result.IncomingChangesets = new ObservableCollection <ExtendedChangeset>(); foreach (Changeset c in repository.IncomingChangesets) { result.IncomingChangesets.Add(GetExtendedChangeset(c)); } result.OutgoingChangesets = new ObservableCollection <ExtendedChangeset>(); foreach (Changeset c in repository.OutgoingChangesets) { result.OutgoingChangesets.Add(GetExtendedChangeset(c)); } return(result); }
public void Attach_Test() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); Entity entity = new Entity() { Id = 5, Field = "test" }; //Act target.RegisterItem(entity); //Assert Assert.IsTrue(target.GetFilteredElements(t => t.Id == 5).Count() == 1); }
private IList <ExtendedRepository> ReadRepositories() { List <ExtendedRepository> result = new List <ExtendedRepository>(); //if (!File.Exists(Constants.Configuration.DbFileName)) // InitializeDatabase(); //Create connection SqliteConnection connection = new SqliteConnection(); connection.ConnectionString = Constants.Configuration.ConnectionString; //Open database connection.Open(); //create command IDbCommand cmd = connection.CreateCommand(); //Select repositories cmd.CommandText = "SELECT * FROM Repositories"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string path = reader.GetString(reader.GetOrdinal("Path")); string name = reader.GetString(reader.GetOrdinal("Name")); string type = reader.GetString(reader.GetOrdinal("RepoType")); ExtendedRepository repo = new ExtendedRepository(type, path); repo.Name = name; if (_pluginService.Plugins.ContainsKey(type)) { repo.PluginIcon = _pluginService.Plugins[type].PluginIcon; } result.Add(repo); } //Close and cleanup connection.Close(); connection = null; return(result); }
public void DeleteTest() { //Arrange IQueryableUnitOfWork unitOfWork = new UnitOfWorkStub(); ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>(); ExtendedRepository <Entity> target = new ExtendedRepository <Entity>(unitOfWork, traceManager); //Act IEnumerable <Entity> result = target.GetAll(); Entity firstEntity = result.First(); target.Remove(firstEntity); IEnumerable <Entity> postResult = target.GetAll(); //Assert Assert.IsNotNull(postResult); Assert.IsFalse(postResult.Contains(firstEntity)); }
public void BeginGetIncomingChanges(ExtendedRepository repository, Action <ExtendedRepository, Exception> callback) { ExtendedRepository result = null; Exception exception = null; try { //Get incoming changesets IPlugin rcsPlugin = _pluginService.Plugins[repository.Type]; result = RepositoryExtensionHelper.GetExtendedRepository(rcsPlugin.GetIncomingChanges(RepositoryExtensionHelper.GetRepository(repository))); //Get Gravatars foreach (ExtendedChangeset changeset in result.IncomingChangesets) { string author = changeset.AuthorEmail; if (_gravatars.ContainsKey(author)) { changeset.Gravatar = _gravatars[author]; } else { BitmapImage gravatar = GravatarHelper.GetBitmapImage(author, rating: GravatarRating.X); if (null != gravatar) { _gravatars.Add(author, gravatar); changeset.Gravatar = gravatar; } } } } catch (Exception ex) { exception = ex; } finally { //Return data callback(result, exception); } }
private void OnDrop(DragEventArgs e) { //var files = e.Data.GetData(DataFormats.FileDrop) as DirectoryInfo[]; //if (null != files && files.Length > 0) //{ // foreach (DirectoryInfo di in files) // { // string path = di.FullName; // } //} string[] repositories = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string path in repositories) { bool repoIsNew = true; ExtendedRepository repository = new ExtendedRepository(string.Empty, path); foreach (ExtendedRepository r in Repositories) { if (string.Equals(path, r.Path)) { repoIsNew = false; break; } } if (repoIsNew && _pluginService.SetRepositoryType(ref repository)) { Repositories.Add(repository); //FIXME: This is ugly. if (string.IsNullOrEmpty(repository.Name)) { string[] s = repository.Path.Split('\\'); string name = s[s.Length - 1]; repository.Name = name; } } } }