public ExecuteQueryCommand(IQueryView view, Project prj, string hqlQueryText, TypedParameter[] typedParameters)
 {
     this.view = view;
     this.prj = prj;
     this.hqlQueryText = hqlQueryText;
     this.typedParameters = typedParameters;
 }
 public void AddingFileTwice()
 {
     Project addFileTwice = new Project("Adding File Twice");
     addFileTwice.AddFile(@"C:\test\driven\design\application.cfg.xml");
     Assert.AreEqual(1, addFileTwice.Files.Count, "Didn't add a file to Files collections");
     addFileTwice.AddFile(@"C:\test\driven\design\application.cfg.xml");
     Assert.AreEqual(1, addFileTwice.Files.Count, "Add a file multiply times");
 }
        public void AddConfigChangeAppSetup()
        {
            Project changeAppSetup = new Project("Add Config Change App Setup");
            changeAppSetup.AddFile(TestDataUtil.TestConfigFile);
            changeAppSetup.AddFile(TestDataUtil.TestDllFile);
            changeAppSetup.AddFile(TestDataUtil.TestMappingFile);

            changeAppSetup.HandleFiles();
            Assert.AreEqual(TestDataUtil.TestConfigFile, changeAppSetup.AppDomainSetup.ConfigurationFile, "Configuration file was not set");
        }
 public void SetUp()
 {
     repository = TestDataUtil.CreateFileRepository();
     current = new Project(projectName);
     current.AddFile(TestDataUtil.TestConfigFile);
     current.AddFile(TestDataUtil.TestDllFile);
     current.AddFile(TestDataUtil.TestMappingFile);
     repository.SaveProject(current);
 }
 public void SeveralProjectsWithQueries()
 {
     Project second = new Project("second");
     Query q = new Query("one", "two");
     second.AddQuery(q);
     repository.SaveProject(second);
     repository.RemoveProject(second);
 }
 public void SetUp()
 {
     prj = new Project("My Test Project");
 }
 public virtual void AddFile(Project toProject)
 {
     if (toProject.logger.IsInfoEnabled)
         toProject.logger.Info("Added mapping file: " + file);
     toProject.mappings.Add(file);
 }
 public void SetUp()
 {
     mocks = new MockRepository();
     prj = mocks.CreateMock(typeof(Project),"New Project") as Project;
     view = mocks.CreateMock(typeof(IQueryView)) as IQueryView;
     query = "from TestProject tp where tp.Id = :id";
     param = new TypedParameter("id",typeof(int),1);
     parameters = new TypedParameter[]
         {  param,	};
     command = new ExecuteQueryCommand(this.view,this.prj,this.query,this.parameters);
 }
 private void BuildingProjectFinishedSuccessfully(Project prj)
 {
     repository.SaveProject(prj);//to save the isBuildSuccessfully flag.
     view.DisplayProjectState(false, true);
     view.EndWait("Project was built successfully");
 }
        public void OpenProjectGetListOfAllProjectsAndShowThemToUser()
        {
            CreatesMockedViewsExpectingToBeClosed(0,false);

            string projectName = "Open Project";
            Project project = new Project(projectName);
            Expect.On(view).Call(view.SelectExistingProject()).Return(project);
            view.Display(null);
            LastCall.On(view).Constraints(
                Is.TypeOf(typeof(IProjectView)) &
                Property.Value("Title", projectName));
            repository.RemoveFromCache(project);
            mocks.ReplayAll();

            IProjectPresenter projectPresenter = presenter.OpenProject();
            DisposePresenterView(projectPresenter);
        }
        public void SaveProjectAs_WithNameConflict_UserApprove()
        {
            Project oldProject = new Project(this.newProjectName);
            Expect.On(projectView).
                Call(projectView.Ask(question,answer)).
                Return( newProjectName);
            Expect.On(projectView).
                Call(projectView.Title).
                Return(prj.Name);
            projectView.Title = newProjectName;
            Expect.On(projectView).
                Call(projectView.AskYesNo(this.overwriteProject,this.overwriteProjecTitle)).
                Return(true);
            projectView.HasChanges = false;

            Expect.On(repository).
                Call(repository.GetProjectByName(newProjectName)).
                Return(oldProject);
            repository.RemoveProject(oldProject);
            repository.SaveProject(prj);
            mocks.ReplayAll();
            Assert.IsTrue(presenter.SaveProjectAs());
            Assert.AreEqual(newProjectName,prj.Name);
        }
 /// <summary>
 /// Removes the project and all its associate data from NQA's database.
 /// </summary>
 /// <param name="project">The project to remove.</param>
 public void RemoveProject(Project project)
 {
     if (logger.IsInfoEnabled)
         logger.Info("Removing project: " + project.Name);
     Session.Delete(project);
     Session.Flush();
 }
 public void SaveProject(Project prj)
 {
     if (prj.Id == 0)
         Session.Save(prj);
     else
         Session.Update(prj);
     Session.Flush();
 }
 public void RemoveFromCache(Project current)
 {
     Session.Evict(current);
 }
 public ProjectPresenterWithMockView(Project prj, IMainPresenter mainPresenter)
     : base(prj, mainPresenter)
 {
 }
 public void SetUp()
 {
     mocks = new MockRepository();
     prj = QueryPresenterTests.BuildProject();
     mainPresenter = (IMainPresenter)mocks.CreateMock(typeof(IMainPresenter));;
     repository = (IProjectsRepository)mocks.CreateMock(typeof(IProjectsRepository));;
     projectView = (IProjectView)mocks.CreateMock(typeof(IProjectView));
     ProjectPresenterWithMockView.MockView = projectView;
     SetupResult.On(mainPresenter).Call(mainPresenter.Repository).Return(repository);
     presenter = new ProjectPresenterWithMockView(prj,mainPresenter);
 }
 public void ProjectCanBeRemovedFromMemory()
 {
     repository.RemoveFromCache(current);
     Project prj = repository.GetProjectById(current.Id);
     Assert.AreNotSame(current, prj, "Returned the same object");
     current = prj;
 }
        public void ResetProjectAfterBuilding()
        {
            Project resetable = new Project("Resetabble Project");
            resetable.AddFile(TestDataUtil.TestConfigFile);
            resetable.AddFile(TestDataUtil.TestDllFile);
            resetable.AddFile(TestDataUtil.TestMappingFile);
            resetable.BuildProject();
            Assert.IsTrue(resetable.IsProjectBuilt, "Project was not built");
            SerializableTestClassForDomainUnload testUnload = new SerializableTestClassForDomainUnload();
            resetable.AppDomain.DomainUnload += new EventHandler(testUnload.AppDomain_DomainUnload);
            resetable.ResetProject();
            Assert.IsFalse(resetable.IsProjectBuilt, "Project was not reset properly");
            Assert.IsTrue(testUnload.ProjectAppDomainWasUnloaded, "Project's AppDomain was not unloaded");
            Assert.IsNull(resetable.AppDomain, "AppDomain was no released.");

            resetable.Dispose();
        }
 public ProjectPresenter(Project prj, IMainPresenter mainPresenter)
 {
     this.mainPresenter = mainPresenter;
     this.prj = prj;
     this.view  = CreateView(mainPresenter);
 }
 public virtual void AddFile(Project parent)
 {
     if (parent.logger.IsErrorEnabled)
         parent.logger.Error("File " + file + " is not an known file.");
     throw new UnknownFileTypeException(file);
 }
        private void ExpectCreateNewProject(ArrayList projects, string projectName)
        {
            repository.GetProjectsStartingWith(MainForm.DefaultNamePrefix);
            LastCall.On(repository).Return(projects);
            repository.CreateProject(projectName);
            Project project = new Project(projectName);
            LastCall.On(repository).Return(project);

            repository.RemoveFromCache(project);
            LastCall.Repeat.Times(0, 1);
        }
 public Query SelectProjectQuery(Project prj)
 {
     using (OpenQueryForm oqf = new OpenQueryForm(prj))
     {
         if (oqf.ShowDialog(this) == DialogResult.OK) { return oqf.SelectedQuery; }
         return null;
     }
 }
 public void TestFixtureSetup()
 {
     current = new Project(prjName, new Project.Context());
     current.AddFile(TestDataUtil.TestConfigFile);
     current.AddFile(TestDataUtil.TestDllFile);
     current.AddFile(TestDataUtil.TestMappingFile);
     current.BuildProject();
 }
 public void ProjectFromNHibernate_HasContextSet()
 {
     repository.RemoveFromCache(current); //remove from session's cache
     Project prj = repository.GetProjectById(current.Id);
     Assert.AreNotSame(current, prj, "Returned the same object");
     Assert.IsNotNull(prj.Conext, "Project created by NHibernate should have a non null context");
     current = prj;
 }
 public void TestFixtureSetup()
 {
     prj = QueryPresenterTests.BuildProject();
     prj.BuildProject();
 }
 public void ProjectStateUdatedInDatabase()
 {
     repository.RemoveFromCache(current);
     Project prj = repository.GetProjectById(current.Id);
     Assert.IsNotNull(prj, "Project was not saved in the database");
     Assert.AreEqual(3, prj.Files.Count, "Files count is wrong");
     CollectionAssert.Contains(prj.Files,TestDataUtil.TestConfigFile);
     CollectionAssert.Contains( prj.Files, TestDataUtil.TestDllFile);
     CollectionAssert.Contains(prj.Files, TestDataUtil.TestMappingFile);
     current = prj;
 }
 public BuildProjectCommand(IProjectView view, Project prj, IProjectsRepository repository)
 {
     this.repository = repository;
     this.view = view;
     this.prj = prj;
 }
 public void SaveProjectQuery()
 {
     Query q = new Query("first query", "first query text");
     current.AddQuery(q);
     repository.SaveQuery(q);
     repository.SaveProject(current);
     repository.RemoveFromCache(current);
     Project prj = repository.GetProjectById(current.Id);
     Assert.AreEqual(1, prj.Queries.Count);
     Assert.IsNotNull(prj.GetQueryWithName(q.Name));
     Assert.AreEqual(q.OwnerProject.Id, prj.Id);
     Query queryWithName = prj.GetQueryWithName(q.Name);
     Assert.AreEqual(q.Text, queryWithName.Text);
     current = prj;
 }
 public OpenQueryForm(Project prj)
 {
     this.prj = prj;
     InitializeComponent();
     BindQueries();
 }
 public virtual void AddFile(Project toProject)
 {
     if (toProject.logger.IsInfoEnabled)
         toProject.logger.Info("Added configuration file: " + file);
     toProject.configurations.Add(file);
 }