public override void MainSetup() { base.MainSetup(); // Set Initial Solution State _MockSolution.Projects.Add(new MockProject { MockSourceFiles = { _sourceFile } }); //Warm Caches by loading solution. var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); //Ensure Basic Class is in the solution Assert.True(null != solution.FindCSharpFileByFileName(_sourceFile.FileName), "Basic File was not found in Solution. Test Environment is not valid."); //Simulate Project Item Removed (Basic Class) _MockSolution.Projects[0].MockSourceFiles.Clear(); //Fire Project Item Event EventProxy.FireOnProjectItemRemoved(this, new ProjectItemRemovedEventArgs { ClassFullPath = _sourceFile.FileName, ProjectFullPath = _MockSolution.Projects[0].FileName }); }
public override void MainSetup() { base.MainSetup(); // Set Initial Solution State _MockSolution.Projects.Add(new MockProject()); //Warm Caches by loading solution. var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); //Ensure Basic Class isn't yet in the solution Assert.True(null == solution.FindCSharpFileByFileName(_sourceFileAdded.FileName), "Basic File was already in Solution. Test Environment is not valid."); //Simulate Project Item added (Basic Class) _MockSolution.Projects[0].MockSourceFiles.Add(_sourceFileAdded); //Fire Project Item Event EventProxy.FireOnProjectItemAdded(this, new ProjectItemAddedEventArgs { ClassFullPath = _sourceFileAdded.FileName, ProjectFullPath = _MockSolution.Projects[0].FileName }); //Wait a Second for the Async reader to catch up. Thread.Sleep(1000); _MockFileWrapper.AssertWasCalled(f => f.ReadAllText(Arg.Is(_sourceFileAdded.FileName))); }
public override void MainSetup() { base.MainSetup(); _MockSolution.InitializeWithTargetAndMixinInSeparateProjects(); //Warm Caches by loading solution. var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); //Ensure All Classes are is in the solution foreach (var file in _MockSolution.AllMockSourceFiles) { Assert.True(null != solution.FindCSharpFileByFileName(file.FileName), "{0} was not found in Solution. Test Environment is not valid.", file.FileName); } //Simulate Project Item Removed (Basic Class) _projectToRemove = _MockSolution.Projects[0]; _MockSolution.Projects = _MockSolution.Projects.Skip(1).ToList(); //Fire Project Item Event EventProxy.FireOnProjectRemoved(this, new ProjectRemovedEventArgs { ProjectFullPath = _projectToRemove.FileName }); }
public void FileShouldBeLoadedIntoSolution() { var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); Assert.True(null != solution, "BuildCurrentSolution() returned a null solution."); var csharpBasicFile = solution.FindCSharpFileByFileName(_sourceFile.FileName); Assert.True(null == csharpBasicFile, "Solution contained Basic Class File"); }
public override void MainSetup() { base.MainSetup(); _PMixinsOnSolutionOpenCodeGenerator = TestSpecificKernel.Get <pMixinsOnSolutionOpenCodeGenerator>(); SetupCodeGeneratorMock(); TestSpecificKernel.Rebind <IVisualStudioCodeGenerator>().ToMethod(x => _mockVisualStudioCodeGenerator); MainSetupInitializeSolution(); this.FireSolutionOpen(); }
public void FileShouldBeLoadedIntoSolution() { var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); Assert.True(null != solution, "BuildCurrentSolution() returned a null solution."); var csharpBasicFile = solution.FindCSharpFileByFileName(_sourceFileAdded.FileName); Assert.True(null != csharpBasicFile, "Solution did not contain Basic Class File"); Assert.True( csharpBasicFile.ResolveTypes() .Any(x => x.FullName.EndsWith(_sourceFileAdded.Classname)), "Failed to Resolve " + _sourceFileAdded.Classname + " IType"); }
public void FileShouldBeLoadedIntoSolution() { var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); Assert.True(null != solution, "BuildCurrentSolution() returned a null solution."); Assert.True(1 == solution.Projects.Count, "Solution did not contain the correct number of Projects (1)"); foreach (var file in _projectToRemove.MockSourceFiles) { Assert.IsNull( solution.FindCSharpFileByFileName(file.FileName), "Solution contained File from Removed Project: [{0}]", file.FileName); } }
private void SetupCodeGeneratorMock() { _actualVisualStudioCodeGenerator = TestSpecificKernel.Get <VisualStudioCodeGenerator>(); _mockVisualStudioCodeGenerator = MockRepository.GenerateMock <IVisualStudioCodeGenerator>(); _mockVisualStudioCodeGenerator.Stub( x => x.GenerateCode(Arg <IEnumerable <ICodeGeneratorContext> > .Is.Anything)) .Do( (Func <IEnumerable <ICodeGeneratorContext>, IEnumerable <CodeGeneratorResponse> >) (_actualVisualStudioCodeGenerator.GenerateCode) ); _mockVisualStudioCodeGenerator.Stub( x => x.GenerateCode(Arg <IEnumerable <RawSourceFile> > .Is.Anything)) .Do( (Func <IEnumerable <RawSourceFile>, IEnumerable <CodeGeneratorResponse> >) (_actualVisualStudioCodeGenerator.GenerateCode) ); }
public override void MainSetup() { base.MainSetup(); //Verify OnSolutionOpen generated code behind this.AssertCodeBehindFileWasGenerated( _MockSolution.Projects[0].MockSourceFiles[1]); _PMixinsOnBuildCodeGenerator = TestSpecificKernel.Get <pMixinsOnBuildCodeGenerator>(); //Delete the code behind _MockSolution.RemoveFile(s => s.AllMockSourceFiles.First(f => f.FileName.FullPath.ToLower().EndsWith(".mixin.cs"))); //Fire OnBuild EventProxy.FireOnBuildBegin(this, new VisualStudioBuildEventArgs { BuildAction = vsBuildAction.vsBuildActionBuild, ProjectFullPath = _MockSolution.Projects[0].FileName, Scope = vsBuildScope.vsBuildScopeSolution }); }
public override void MainSetup() { base.MainSetup(); _MockSolution.Projects.Add( new MockProject(Path.Combine(MockSolution.MockSolutionFolder, "OtherProject.csproj")) { MockSourceFiles = { _mixinSourceFile } }); _MockSolution.Projects.Add( new MockProject() { MockSourceFiles = { _targetSourceFile }, ProjectReferences = { _MockSolution.Projects[0] }, AssemblyReferences = ReferenceHelper.GetDefaultSystemReferences() .Union( new [] { ReferenceHelper.GetReferenceToPMixinsDll() }) .ToList() }); //Simulate Solution Opening event EventProxy.FireOnSolutionOpening(this, new EventArgs()); //Simulate Item Saved EventProxy.FireOnProjectItemSaved(this, new ProjectItemSavedEventArgs { ClassFullPath = _mixinSourceFile.FileName, ProjectFullPath = _MockSolution.Projects[1].FileName }); //Update _targetSourceFile to have a Mixin _targetSourceFile.Source = _updatedTargetSourceFileSource; EventProxy.FireOnProjectItemSaved(this, new ProjectItemSavedEventArgs { ClassFullPath = _targetSourceFile.FileName, ProjectFullPath = _MockSolution.Projects[1].FileName }); //Update _mixinSourceFile to have a new Method _mixinSourceFile.Source = _updatedMixinFileSource; EventProxy.FireOnProjectItemSaved(this, new ProjectItemSavedEventArgs { ClassFullPath = _mixinSourceFile.FileName, ProjectFullPath = _MockSolution.Projects[0].FileName }); var solution = TestSpecificKernel.Get <ISolutionFactory>() .BuildCurrentSolution(); Assert.True(null != solution); }
// ReSharper restore NotAccessedField.Global public override void MainSetup() { base.MainSetup(); _PMixinsOnItemSaveCodeGenerator = TestSpecificKernel.Get <pMixinsOnItemSaveCodeGenerator>(); }