public SemanticChangeProcessor( IAsynchronousOperationListener listener, Registration registration, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _gate = new SemaphoreSlim(initialCount: 0); _registration = registration; _processor = new ProjectProcessor(listener, registration, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <DocumentId, Data>(); Start(); // Register a clean-up task to ensure pending work items are flushed from the queue if they will // never be processed. AsyncProcessorTask.ContinueWith( _ => ClearQueueWorker(_workGate, _pendingWork, data => data.AsyncToken), CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
static void Main() { var config = new Config(); var processor = new ProjectProcessor(config); var project = processor.GetProjectData(); processor.DisplayProjectInfo(project); }
static void Main(string[] args) { if (args.Count() > 0 && args[0] is string) { string filePath = args[0]; ProjectProcessor p = new ProjectProcessor(filePath); p.MyFileWorker = new FileWorker(); p.MyMessageProcessor = new MessageProcessor(); p.ProcessArchive(); } }
public Project GetProject(int projectId) { var data = ProjectProcessor.GetProject(projectId); Project = new Project( ) { ProjectId = data.ProjectId, Name = data.Name, ProjectRoleGroupId = data.ProjectRoleGroupId }; return(Project); }
private static void Main(string[] args) { string projectFileName; if (args.Length == 1) { projectFileName = args[0]; } else { Console.WriteLine("Задайте имя файла проекта в параметрах запуска, или введите сейчас:"); Console.ForegroundColor = ConsoleColor.Yellow; projectFileName = Console.ReadLine(); Console.ResetColor(); if (string.IsNullOrWhiteSpace(projectFileName)) { return; } } // try // { var loader = new XmlProjectLoader(projectFileName); GenerationProject project = loader.Load(); IProjectProcessor projectProcessor = new ProjectProcessor(); projectProcessor.Process(project); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Проект успешно обработан."); Console.ResetColor(); // } // catch (Exception e) // { // if (Debugger.IsAttached) // throw; // // Console.WriteLine("Во время выполнения программы возникло исключение:"); // Console.ForegroundColor = ConsoleColor.Red; // Console.WriteLine(e.Message); // Console.ForegroundColor = ConsoleColor.DarkRed; // Console.WriteLine(e); // Console.ResetColor(); // Console.ReadLine(); // } }
public void Init() { _projectRepository = Substitute.For <IEntityBaseRepository <Project> >(); _solutionRepository = Substitute.For <IEntityBaseRepository <Solution> >(); _sharedProjectRepository = Substitute.For <IEntityBaseRepository <SharedProject> >(); _projectEntityToProjectDetailDtoMapper = Substitute.ForPartsOf <ProjectEntityToProjectDetailDtoMapper>(); _solutionEntityToSolutionHeaderDetailsDtoMapper = Substitute.ForPartsOf <SolutionEntityToSolutionHeaderDetailsDtoMapper>(); _projectProcessor = Substitute.For <ProjectProcessor> (_projectRepository, _solutionRepository, _sharedProjectRepository, _projectEntityToProjectDetailDtoMapper, _solutionEntityToSolutionHeaderDetailsDtoMapper); }
public async Task <HttpResponseMessage> Update(ProjectRequest req) { IProject p = new Project(); req.CopyRequestToProject(p); var ep = new ProjectProcessor(p); var res = await ep.Update(); if (res != null && res.Success) { return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(new { Id = res.Data.Id.ToString() })) }); } return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)); }
public ActionResult Edit(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Check if a project ID was provided if (id == null) { return(RedirectToIndex()); } int projectId = (int)id; // Entry try-catch from here // Make sure any errors are displayed try { // Get the project data var projectModel = ProjectProcessor.GetProject(projectId); if (projectModel == null) { return(RedirectToIndexIdNotFound(projectId)); } // Get all project role groups from the database var projectRoleGroupModels = ProjectRoleGroupProcessor.GetAllProjectRoleGroups(); // Get list of available project role groups // Store it in a list for a drop-down-list ViewBag.RoleGroup = new SelectList(projectRoleGroupModels, "ProjectRoleGroupId", "Name", projectModel.ProjectRoleGroupId); // Convert the model data to non-model data // Pass the data to the view return(View(new Project(projectModel, projectRoleGroupModels))); } catch (Exception e) { return(RedirectToIndex(e)); } }
public ActionResult CreateProject(UIProjectModel model) { if (ModelState.IsValid) { ProjectProcessor.CreateProject(model.Name, model.Key, model.Type, model.Category, model.URL, model.ProjectLead //put username here. //User.Identity.GetUserName(), ); return(RedirectToAction("ViewProjects")); } return(View()); }
public List <Project> GetProjects( ) { var data = ProjectProcessor.GetAllProjects( ); Projects = new List <Project>( ); foreach (var row in data) { var project = new Project( ) { ProjectId = row.ProjectId, Name = row.Name, ProjectRoleGroupId = row.ProjectRoleGroupId }; Projects.Add(project); } return(Projects); }
public ActionResult Edit(Project project) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Make sure the entered data is valid if (ModelState.IsValid) { // Update the project within the database try { ProjectProcessor.UpdateProject( project.ProjectId, project.Name, project.Description, project.ProjectRoleGroupId); TempData[LabelSuccess] = "Updated project: " + project.Name; return(RedirectToIndex()); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } else { //show error var errors = ModelState.Values.SelectMany(v => v.Errors); } // Get list of available project role groups // Store it in a list for a drop-down-list ViewBag.RoleGroup = new SelectList(ProjectRoleGroupProcessor.GetAllProjectRoleGroups(), "ProjectRoleGroupId", "Name", project.ProjectRoleGroupId); // Return to same page with same data return(View(project)); }
public ActionResult Details(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Check if a project ID was provided if (id == null) { return(RedirectToIndex()); } int projectId = (int)id; // Entry try-catch from here // Make sure any errors are displayed try { // Get the project data var projectModel = ProjectProcessor.GetProject(projectId); if (projectModel == null) { return(RedirectToIndexIdNotFound(projectId)); } // Get name of assigned project role group var roleGroup = ProjectRoleGroupProcessor.GetProjectRoleGroup(projectModel.ProjectRoleGroupId); //var teams = TeamProcessor.SelectTeamsForUnitOfferingId( projectId ); // Convert the model data to non-model data // Pass the data to the view return(View(new Project(projectModel, roleGroup))); } catch (Exception e) { return(RedirectToIndex(e)); } }
public SemanticChangeProcessor( IAsynchronousOperationListener listener, Registration registration, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _gate = new AsyncSemaphore(initialCount: 0); _registration = registration; _processor = new ProjectProcessor(listener, registration, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <DocumentId, Data>(); Start(); }
public ActionResult ViewProjects() { ViewBag.Message = "Projects List"; var data = ProjectProcessor.LoadProjects(); List <UIProjectModel> projects = new List <UIProjectModel>(); foreach (var project in data) { projects.Add(new UIProjectModel { Id = project.Id, Name = project.Name, Key = project.Key, Type = project.Type, Category = project.Category, URL = project.URL, ProjectLead = project.ProjectLead.ToString() }); } return(View(projects)); }
public async Task <HttpResponseMessage> Get(Guid id) { if (id != Guid.Empty) { var ep = new ProjectProcessor(id); var e = await ep.FetchById(); if (e.Data != null) { return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(e.Data)) }); } else { return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound)); } } return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)); }
public ActionResult Details(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.ProjectOffering)) { return(RedirectToPermissionDenied()); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { int projectOfferingId = ( int )id; var projectOfferingModel = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(projectOfferingId); if (projectOfferingModel == null) { return(RedirectToIndexIdNotFound(projectOfferingId)); } var project = ProjectProcessor.GetProject(projectOfferingModel.ProjectId); var unitOffering = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(projectOfferingModel.UnitOfferingId); var teams = TeamProcessor.SelectTeamsForProjectOfferingId(projectOfferingModel.ProjectOfferingId); var projectOffering = new ProjectOffering(projectOfferingModel, project, unitOffering, teams); return(View(projectOffering)); } catch (Exception e) { return(RedirectToIndex(e)); } }
public ActionResult Delete(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Check if a project ID was provided if (id == null) { return(RedirectToIndex()); } int projectId = (int)id; // Entry try-catch from here // Make sure any errors are displayed try { // Get the project data var projectModel = ProjectProcessor.GetProject(projectId); if (projectModel == null) { return(RedirectToIndexIdNotFound(projectId)); } // Convert the model data to non-model data // Pass the data to the view return(View(new Project(projectModel))); } catch (Exception e) { return(RedirectToIndex(e)); } }
public async Task <HttpResponseMessage> Delete(ProjectRequest req) { if (req.Id != Guid.Empty) { var ep = new ProjectProcessor(req.Id); var e = await ep.Delete(); if (e > 0) { return(new HttpResponseMessage() { Content = new StringContent(Convert.ToBoolean(e).ToString()), StatusCode = System.Net.HttpStatusCode.OK }); } else { return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound)); } } return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)); }
public void TestProjectCRUD() { IProject p = CreateProject(); var pp = new ProjectProcessor(p); var save = pp.Create().Result; Assert.IsTrue(save.Data != null && save.Data.Id != Guid.Empty, "Project save failed."); var one = pp.FetchById().Result; Assert.IsTrue(one.Data != null, "Project fetch failed."); var eHelper = new EventProcessor(p.Events[0].Id); var eOne = eHelper.FetchById().Result; Assert.IsTrue(eOne.Data != null, "Event fetch failed."); var delete = pp.Delete().Result; one = pp.FetchById().Result; Assert.IsTrue(one.Data == null, "Project delete failed."); eOne = eHelper.FetchById().Result; Assert.IsTrue(eOne.Data == null, "Event delete failed from Project."); var vhelper = new VendorProcessor(p.Events[0].Arrangements[0].Vendor.Id); delete = vhelper.Delete().Result; var vendor = vhelper.FetchById().Result; Assert.IsTrue(one.Data == null, "Vendor delete failed."); var uHelper = new UserProcessor(p.Events[0].Arrangements[0].Vendor.Id); var user = uHelper.FetchById().Result; Assert.IsTrue(user.Data == null, "User not deleted from vendor delete."); }
public SemanticChangeProcessor( IAsynchronousOperationListener listener, int correlationId, Workspace workspace, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { this.gate = new AsyncSemaphore(initialCount: 0); this.correlationId = correlationId; this.workspace = workspace; this.processor = new ProjectProcessor(listener, correlationId, workspace, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); this.workGate = new NonReentrantLock(); this.pendingWork = new Dictionary <DocumentId, Data>(); Start(); }
public async Task <HttpResponseMessage> DeleteEvents(ProjectRequest req) { if (req.Id != Guid.Empty) { if (req.Events != null && req.Events.Any()) { var ep = new ProjectProcessor(req.Id); List <IEvent> list = new List <IEvent>(); foreach (var ar in req.Events) { IEvent e = EventBase.GetEventFromType(ar.Type); e.Id = ar.Id; list.Add(e); } await ep.DeleteEvents(list); return(new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK }); } } return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest)); }
public ActionResult Delete(Project project) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Delete the project from the database try { ProjectProcessor.DeleteProject(project.ProjectId); TempData[LabelSuccess] = "Deleted project: " + project.Name; return(RedirectToIndex()); } catch (Exception e) { return(RedirectToIndex(e)); } }
public void SimpleFolder() { //arrange ProjectProcessor proc = new ProjectProcessor(@"c:\test\archinveWithImages.zip"); var moqFile = new Mock<IFileWorker>(MockBehavior.Strict); proc.MyFileWorker = moqFile.Object; int callBackCounter = 0; int orderCounter = 0; Dictionary<string, int> callOrderDictionary = new Dictionary<string, int>(); moqFile.Setup(x => x.CreateDirectory(@"c:\test\archinveWithImages")).Returns(new DirectoryInfo(@"c:\test\archinveWithImages")).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["CreateDirectory"]))); moqFile.Setup(x => x.ProcessStart(It.IsAny<string>(), @" x ""c:\test\archinveWithImages.zip"" ""c:\test\archinveWithImages""")).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)+"zip"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStartzip"]))); //moqFile.Setup(x => x.EnumerateFiles(@"c:\test\archinveWithImages", "*.sln", SearchOption.AllDirectories)).Returns(new string[] { }).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)+"sln"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFilessln"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\archinveWithImages", "*.csproj", SearchOption.AllDirectories)).Returns(new string[] { }).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)+"csproj"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFilescsproj"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\archinveWithImages", "*.vbproj", SearchOption.AllDirectories)).Returns(new string[] { }).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles"]))); moqFile.Setup(x => x.ProcessStart(@"c:\test\archinveWithImages")).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart"]))); //act proc.ProcessArchive(); //assert Assert.AreEqual(5, callBackCounter); }
public void NotIstalledMajorZeroMinor_OpenFolder() { //arrange ProjectProcessor proc = new ProjectProcessor(@"c:\test\testSolution.rar"); var moqFile = new Mock<IFileWorker>(MockBehavior.Strict); proc.MyFileWorker = moqFile.Object; int callBackCounter = 0; int orderCounter = 0; Dictionary<string, int> callOrderDictionary = new Dictionary<string, int>(); moqFile.Setup(x => x.CreateDirectory(@"c:\test\testSolution")).Returns(new DirectoryInfo(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary["CreateDirectory"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["CreateDirectory"]))); moqFile.Setup(x => x.ProcessStart(It.IsAny<string>(), @" x ""c:\test\testSolution.rar"" ""c:\test\testSolution""")).Do((x3) => { callOrderDictionary["ProcessStart3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart3"]))); //moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.sln", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\testSolution.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles1"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.csproj", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\testSolution.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles"]))); var moqCSProj = new Mock<ICSProjProcessor>(MockBehavior.Strict); proc.csProjProcessor = moqCSProj.Object; var lstRegistryVersions = new List<string>(); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 15.2\Components\"); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 16.1\Components\"); moqFile.Setup(x => x.GetRegistryVersions(It.IsAny<string>())).Returns(lstRegistryVersions).Do((x3) => { callOrderDictionary["GetRegistryVersions"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetRegistryVersions"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 15.2\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName1"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 16.1\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=16.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName"]))); moqCSProj.Setup(x => x.GetCurrentVersion()).Returns(new Version("14.2.0")).Do((x3) => { callOrderDictionary["GetCurrentVersion"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetCurrentVersion"]))); var moqMessage = new Mock<IMessageProcessor>(MockBehavior.Strict); proc.MyMessageProcessor = moqMessage.Object; // string lst = "15.1.16\r\n14.2.3\r\n16.1.1\r\n14.2.13\r\n9.8.1"; XElement xlEl = new XElement("AllVersions"); xlEl.Value = "16.1.1\n15.1.16\n14.2.13\n14.2.8\n14.2.3\n9.8.1"; XElement xlRoot = new XElement("Versions"); xlRoot.Add(xlEl); XDocument xDoc = new XDocument(); xDoc.Add(xlRoot); moqFile.Setup(x => x.LoadXDocument(It.IsAny<string>())).Returns(xDoc).Do((x3) => { callOrderDictionary["LoadXDocument"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["LoadXDocument"]))); moqMessage.Setup(x => x.ConsoleWrite("The current project version is ")).Do((x3) => { callOrderDictionary["ConsoleWrite7"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite7"]))); moqMessage.Setup(x => x.ConsoleWrite("142.0.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite6"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite6"]))); moqMessage.Setup(x => x.ConsoleWriteLine()); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("142.13.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite5"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite5"]))); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("1", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite4"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite4"]))); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("161.4.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite3"]))); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("2", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite2"]))); moqMessage.Setup(x => x.ConsoleWrite("To open folder press: ")).Do((x3) => { callOrderDictionary["ConsoleWrite1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite1"]))); moqMessage.Setup(x => x.ConsoleWrite("9", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite"]))); moqMessage.Setup(x => x.ConsoleReadKey(false)).Returns(ConsoleKey.D9).Do((x3) => { callOrderDictionary["ConsoleReadKey"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleReadKey"]))); moqFile.Setup(x => x.ProcessStart(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary["ProcessStart"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart"]))); //act proc.ProcessArchive(); //assert Assert.AreEqual(18, callBackCounter); }
private void GetProjectOffering(int id) { var data = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(id); ProjectOffering = new ProjectOffering( ) { ProjectOfferingId = data.ProjectOfferingId, ProjectId = data.ProjectId, UnitOfferingId = data.UnitOfferingId }; var projectData = ProjectProcessor.GetProject(data.ProjectId); ProjectOffering.Project = new Project( ) { ProjectId = projectData.ProjectId, ProjectRoleGroupId = projectData.ProjectRoleGroupId, Name = projectData.Name }; var unitOfferingData = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(data.UnitOfferingId); ProjectOffering.UnitOffering = new UnitOffering( ) { UnitOfferingId = unitOfferingData.UnitOfferingId, TeachingPeriodId = unitOfferingData.TeachingPeriodId, YearId = unitOfferingData.YearId, ConvenorId = unitOfferingData.ConvenorId, UnitId = unitOfferingData.UnitId, }; var teachingperiodData = TeachingPeriodProcessor.SelectTeachingPeriodForTeachingPeriodId(ProjectOffering.UnitOffering.TeachingPeriodId); ProjectOffering.UnitOffering.TeachingPeriod = new TeachingPeriod( ) { TeachingPeriodId = teachingperiodData.TeachingPeriodId, Name = teachingperiodData.Name, Day = teachingperiodData.Day, Month = teachingperiodData.Month }; var yearData = YearProcessor.SelectYearForYearId(ProjectOffering.UnitOffering.YearId); ProjectOffering.UnitOffering.Year = new Year( ) { YearId = yearData.YearId, YearValue = yearData.Year }; var convenorData = UserProcessor.SelectUserForUserId(ProjectOffering.UnitOffering.ConvenorId); ProjectOffering.UnitOffering.Convenor = new User( ) { UserId = convenorData.UserId, Username = convenorData.Username }; var unitData = UnitProcessor.SelectUnitForUnitId(ProjectOffering.UnitOffering.UnitId); ProjectOffering.UnitOffering.Unit = new Unit( ) { UnitId = unitData.UnitId, Name = unitData.Name }; }
/// <summary> /// The main page of the project controller. /// Shows a list of all projects in the system. /// </summary> public ActionResult Index() { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.Project)) { return(RedirectToPermissionDenied()); } // Set the page message ViewBag.Message = "Project List"; // Get all projects from the database var projectModels = ProjectProcessor.GetAllProjects(); /*List<TCABS_DataLibrary.Models.ProjectModel> projectModels = * canModify ? * ProjectProcessor.GetAllProjects() : * ProjectOfferingProcessor.GetProjectOfferingsForUserId(CurrentUser.UserId); */ // Get all project role groups from the database // Convert the list to a dictionary var projectRoleGroupModels = ProjectRoleGroupProcessor.GetAllProjectRoleGroups(); Dictionary <int, string> projectRoleGroup = null; if (projectRoleGroupModels != null) { projectRoleGroup = new Dictionary <int, string>(); foreach (var i in projectRoleGroupModels) { projectRoleGroup.Add(i.ProjectRoleGroupId, i.Name); } } // Create the project list List <Project> projects = new List <Project>(); if (projectRoleGroup != null) { foreach (var p in projectModels) { projects.Add(new Project(p, projectRoleGroup)); } } else { foreach (var p in projectModels) { projects.Add(new Project(p)); } } // Make sure the project descriptions are not too long const int maxDescriptionLength = 40; foreach (var p in projects) { if ((p.Description != null) && (p.Description.Length > maxDescriptionLength)) { p.Description = p.Description.Substring(0, maxDescriptionLength - 3) + "..."; } } // Return the view, with the list of projects return(View(projects)); }
public void MajorLastMinor_OpenSolution() { //arrange ProjectProcessor proc = new ProjectProcessor(@"c:\test\testSolution.rar"); var moqFile = new Mock<IFileWorker>(MockBehavior.Strict); proc.MyFileWorker = moqFile.Object; int callBackCounter = 0; int orderCounter = 0; Dictionary<string, int> callOrderDictionary = new Dictionary<string, int>(); moqFile.Setup(x => x.CreateDirectory(@"c:\test\testSolution")).Returns(new DirectoryInfo(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary["CreateDirectory"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["CreateDirectory"]))); moqFile.Setup(x => x.ProcessStart(It.IsAny<string>(), @" x ""c:\test\testSolution.rar"" ""c:\test\testSolution""")).Do((x3) => { callOrderDictionary["ProcessStart2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart2"]))); //moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.sln", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\testSolution.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles1"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.csproj", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\testSolution.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles"]))); var moqCSProj = new Mock<ICSProjProcessor>(MockBehavior.Strict); proc.csProjProcessor = moqCSProj.Object; var lstRegistryVersions = new List<string>(); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 15.2\Components\"); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 16.1\Components\"); moqFile.Setup(x => x.GetRegistryVersions(It.IsAny<string>())).Returns(lstRegistryVersions).Do((x3) => { callOrderDictionary["GetRegistryVersions"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetRegistryVersions"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 15.2\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName1"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 16.1\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=16.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName"]))); moqCSProj.Setup(x => x.GetCurrentVersion()).Returns(new Version("15.2.7")).Do((x3) => { callOrderDictionary["GetCurrentVersion"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetCurrentVersion"]))); var moqMessage = new Mock<IMessageProcessor>(MockBehavior.Strict); proc.MyMessageProcessor = moqMessage.Object; moqMessage.Setup(x => x.ConsoleWrite("The current project version is ")).Do((x3) => { callOrderDictionary["ConsoleWrite7"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite7"]))); moqMessage.Setup(x => x.ConsoleWrite("152.7.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite6"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite6"]))); moqMessage.Setup(x => x.ConsoleWriteLine()); moqMessage.Setup(x => x.ConsoleWrite("To open solution press: ")).Do((x3) => { callOrderDictionary["ConsoleWrite5"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite5"]))); moqMessage.Setup(x => x.ConsoleWrite("1", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite4"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite4"]))); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("161.4.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite3"]))); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("2", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite2"]))); moqMessage.Setup(x => x.ConsoleWrite("To open folder press: ")).Do((x3) => { callOrderDictionary["ConsoleWrite1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite1"]))); moqMessage.Setup(x => x.ConsoleWrite("9", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite"]))); moqMessage.Setup(x => x.ConsoleReadKey(false)).Returns(ConsoleKey.D1).Do((x3) => { callOrderDictionary["ConsoleReadKey"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleReadKey"]))); moqCSProj.Setup(x => x.DisableUseVSHostingProcess()).Do((x3) => { callOrderDictionary["DisableUseVSHostingProcess"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["DisableUseVSHostingProcess"]))); moqCSProj.Setup(x => x.RemoveLicense()).Do((x3) => { callOrderDictionary["RemoveLicense"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["RemoveLicense"]))); //moqCSProj.Setup(x => x.SetSpecificVersionFalse()).Do((x3) => { callOrderDictionary["SetSpecificVersionFalse"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["SetSpecificVersionFalse"]))); moqCSProj.Setup(x => x.SaveNewCsProj()).Do((x3) => { callOrderDictionary["SaveNewCsProj"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["SaveNewCsProj"]))); //moqFile.Setup(x => x.ProcessStart(@"C:\Program Files (x86)\DevExpress 16.1\Components\Tools\Components\ProjectConverter-console.exe", @"""c:\test\dxExample""", true)).Do((x3) => { callOrderDictionary["ProcessStart1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart1"]))); moqFile.Setup(x => x.ProcessStart(@"c:\test\testSolution\testSolution\testSolution.csproj")).Do((x3) => { callOrderDictionary["ProcessStart"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart"]))); //act proc.ProcessArchive(); //assert Assert.AreEqual(20, callBackCounter); }
public void MoreThanOneSolutions_HasDX() { //arrange ProjectProcessor proc = new ProjectProcessor(@"c:\test\testSolution.rar"); var moqFile = new Mock<IFileWorker>(MockBehavior.Strict); proc.MyFileWorker = moqFile.Object; int callBackCounter = 0; int orderCounter = 0; Dictionary<string, int> callOrderDictionary = new Dictionary<string, int>(); moqFile.Setup(x => x.CreateDirectory(@"c:\test\testSolution")).Returns(new DirectoryInfo(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary["CreateDirectory"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["CreateDirectory"]))); moqFile.Setup(x => x.ProcessStart(It.IsAny<string>(), @" x ""c:\test\testSolution.rar"" ""c:\test\testSolution""")).Do((x3) => { callOrderDictionary["ProcessStart3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart3"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.csproj", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\solution1\solution1.csproj", @"c:\test\testSolution\testSolution\solution2\solution2.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles"]))); moqFile.Setup(x => x.StreamReaderReadToEnd(@"c:\test\testSolution\testSolution\solution1\solution1.csproj")).Returns("test string").Do((x3) => { callOrderDictionary["StreamReaderReadToEnd3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["StreamReaderReadToEnd3"]))); moqFile.Setup(x => x.StreamReaderReadToEnd(@"c:\test\testSolution\testSolution\solution2\solution2.csproj")).Returns("test string DevExpress.Xpf.Grid").Do((x3) => { callOrderDictionary["StreamReaderReadToEnd2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["StreamReaderReadToEnd2"]))); var moqCSProj = new Mock<ICSProjProcessor>(MockBehavior.Strict); proc.csProjProcessor = moqCSProj.Object; var lstRegistryVersions = new List<string>(); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 15.2\Components\"); lstRegistryVersions.Add(@"C:\Program Files (x86)\DevExpress 16.1\Components\"); moqFile.Setup(x => x.GetRegistryVersions(It.IsAny<string>())).Returns(lstRegistryVersions).Do((x3) => { callOrderDictionary["GetRegistryVersions"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetRegistryVersions"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 15.2\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName1"]))); moqFile.Setup(x => x.AssemblyLoadFileFullName(@"C:\Program Files (x86)\DevExpress 16.1\Components\Tools\Components\ProjectConverter-console.exe")).Returns(@"ProjectConverter, Version=16.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a").Do((x3) => { callOrderDictionary["AssemblyLoadFileFullName"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["AssemblyLoadFileFullName"]))); moqCSProj.Setup(x => x.GetCurrentVersion()).Returns(new Version("15.2.5")).Do((x3) => { callOrderDictionary["GetCurrentVersion"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["GetCurrentVersion"]))); var moqMessage = new Mock<IMessageProcessor>(MockBehavior.Strict); proc.MyMessageProcessor = moqMessage.Object; moqMessage.Setup(x => x.ConsoleWrite("The current project version is ")).Do((x3) => { callOrderDictionary["ConsoleWrite11"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite11"]))); moqMessage.Setup(x => x.ConsoleWrite("152.5.0", ConsoleColor.Red)); moqMessage.Setup(x => x.ConsoleWriteLine()); //moqMessage.Setup(x => x.ConsoleWrite("To open solution press: ")).Do((x3) => { callOrderDictionary["ConsoleWrite9"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite9"]))); //moqMessage.Setup(x => x.ConsoleWrite("1", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite8"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite8"]))); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("152.7.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite7"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite7"]))); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("1", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite6"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite6"]))); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("161.4.0", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite5"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite5"]))); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("2", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite4"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite4"]))); moqMessage.Setup(x => x.ConsoleWrite("To convert to : ")); moqMessage.Setup(x => x.ConsoleWrite("152.5.0", ConsoleColor.Red)); moqMessage.Setup(x => x.ConsoleWrite(" press ")); moqMessage.Setup(x => x.ConsoleWrite("3", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite2"]))); moqMessage.Setup(x => x.ConsoleWrite("To open folder press: ")).Do((x3) => { callOrderDictionary["ConsoleWrite1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite1"]))); moqMessage.Setup(x => x.ConsoleWrite("9", ConsoleColor.Red)).Do((x3) => { callOrderDictionary["ConsoleWrite"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleWrite"]))); moqMessage.Setup(x => x.ConsoleReadKey(false)).Returns(ConsoleKey.D3).Do((x3) => { callOrderDictionary["ConsoleReadKey"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ConsoleReadKey"]))); moqCSProj.Setup(x => x.DisableUseVSHostingProcess()).Do((x3) => { callOrderDictionary["DisableUseVSHostingProcess"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["DisableUseVSHostingProcess"]))); moqCSProj.Setup(x => x.RemoveLicense()).Do((x3) => { callOrderDictionary["RemoveLicense"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["RemoveLicense"]))); // moqCSProj.Setup(x => x.SetSpecificVersionFalse()).Do((x3) => { callOrderDictionary["SetSpecificVersionFalse"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["SetSpecificVersionFalse"]))); moqCSProj.Setup(x => x.SaveNewCsProj()).Do((x3) => { callOrderDictionary["SaveNewCsProj"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["SaveNewCsProj"]))); moqFile.Setup(x => x.DirectoryEnumerateFiles(@"c:\test\testSolution", "DevExpress*.dll", SearchOption.AllDirectories)).Returns(new string[] { }).Do((x3) => { callOrderDictionary["DirectoryEnumerateFiles"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["DirectoryEnumerateFiles"]))); moqCSProj.Setup(x => x.DXLibrariesCount).Returns(1).Do((x3) => { callOrderDictionary["DXLibrariesCount"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["DXLibrariesCount"]))); // moqFile.Setup(x => x.ProcessStart(@"C:\Program Files (x86)\DevExpress 16.1\Components\Tools\Components\ProjectConverter-console.exe", @"""c:\test\testSolution""", true)).Do((x3) => { callOrderDictionary["ProcessStart2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart2"]))); var arguments = string.Format("\"{0}\" \"{1}\" \"false\"", @"c:\test\testSolution", "15.2.5"); moqFile.Setup(x => x.ProcessStart(@"c:\Dropbox\Deploy\DXConverterDeploy\DXConverter.exe", arguments)).Do((x3) => { callOrderDictionary["ProcessStart1"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart1"]))); moqFile.Setup(x => x.ProcessStart(@"c:\test\testSolution\testSolution\solution2\solution2.csproj")).Do((x3) => { callOrderDictionary["ProcessStart"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart"]))); //act proc.ProcessArchive(); //assert Assert.AreEqual(25, callBackCounter); }
public void MoreThanOneSolutions_NotDX() { //arrange ProjectProcessor proc = new ProjectProcessor(@"c:\test\testSolution.rar"); var moqFile = new Mock<IFileWorker>(MockBehavior.Strict); proc.MyFileWorker = moqFile.Object; int callBackCounter = 0; int orderCounter = 0; Dictionary<string, int> callOrderDictionary = new Dictionary<string, int>(); moqFile.Setup(x => x.CreateDirectory(@"c:\test\testSolution")).Returns(new DirectoryInfo(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary["CreateDirectory"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["CreateDirectory"]))); moqFile.Setup(x => x.ProcessStart(It.IsAny<string>(), @" x ""c:\test\testSolution.rar"" ""c:\test\testSolution""")).Do((x3) => { callOrderDictionary["ProcessStart3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart3"]))); moqFile.Setup(x => x.EnumerateFiles(@"c:\test\testSolution", "*.csproj", SearchOption.AllDirectories)).Returns(new string[] { @"c:\test\testSolution\testSolution\solution1\solution1.csproj", @"c:\test\testSolution\testSolution\solution2\solution2.csproj" }).Do((x3) => { callOrderDictionary["EnumerateFiles"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["EnumerateFiles"]))); moqFile.Setup(x => x.StreamReaderReadToEnd(@"c:\test\testSolution\testSolution\solution1\solution1.csproj")).Returns("test string").Do((x3) => { callOrderDictionary["StreamReaderReadToEnd3"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["StreamReaderReadToEnd3"]))); moqFile.Setup(x => x.StreamReaderReadToEnd(@"c:\test\testSolution\testSolution\solution2\solution2.csproj")).Returns("test string Xpf.Grid").Do((x3) => { callOrderDictionary["StreamReaderReadToEnd2"] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["StreamReaderReadToEnd2"]))); moqFile.Setup(x => x.ProcessStart(@"c:\test\testSolution")).Do((x3) => { callOrderDictionary[ReturnNameDelete(x3)] = orderCounter++; }).Callback(() => Assert.That(callBackCounter++, Is.EqualTo(callOrderDictionary["ProcessStart"]))); //act proc.ProcessArchive(); //assert Assert.AreEqual(6, callBackCounter); }