protected override void Initialize() { base.Initialize(); var componentModel = this.GetService <SComponentModel, IComponentModel>(); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); this.trackSelection = this.GetService <SVsTrackSelectionEx, IVsTrackSelectionEx>(); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.trackSelection.OnSelectChange(this.selectionContainer)); var shell = this.GetService <SVsUIShell, IVsUIShell>(); var context = new SolutionBuilderContext { PatternManager = this.PatternManager, UserMessageService = this.UserMessageService, BindingFactory = this.BindingFactory, NewProductDialogFactory = ctx => shell.CreateDialog <AddNewProductView>(ctx), NewNodeDialogFactory = ctx => shell.CreateDialog <AddNewNodeView>(ctx), ShowProperties = this.ShowProperties }; this.viewModel = new SolutionBuilderViewModel(context, this.ServiceProvider); this.Content = new SolutionBuilderView { DataContext = this.viewModel }; }
public void build_project_with_assembly_info_fubu_test(SolutionBuilderContext context, ISolutionContext solutionContext, FubuCsProjFile.CsProjFile project) { "Given I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "When I call build with a solution, a project and an assembly info" ._(() => solutionContext = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => { item.Title = "FrodoFx"; item.Description = "Middle earth web server"; item.FileVersion = new Version(0, 0, 1, 2049); item.Version = new Version(0, 0, 1); item.InformationalVersion = "release"; }) .Build()); "It should return the build project with an assembly info" ._(() => { project = new CsProjFile(solutionContext.Solution.Projects.FirstOrDefault().Path); project.Should().NotBeNull("the project should not be null"); project.AssemblyInfo.Should().NotBeNull("the assembly info should not be null"); }); "And the assembly info title should be set" ._(() => project.AssemblyInfo.AssemblyTitle.Should().Be("FrodoFx")) .Teardown(() => context.TearDown()); }
public void build_solution_with_projects_in_sibling_directories(SolutionBuilderContext context, ISolutionContext result, Project project) { "Given I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "When I call build" ._(() => result = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Solutions", "MySolution.sln")) .WithProject(item => { item.Name = "ServiceStack"; item.Path = Path.Combine(context.RootDirectory, "ServiceStack", "ServiceStack.csproj"); }).Build()); "It should return the build project" ._(() => { project = result.Solution.Projects.FirstOrDefault(); project.Should().NotBeNull(); }); "And the project file should have the name set correctly" ._(() => project.Name.Should().Be("ServiceStack")); "And the project file should exist on disk" ._(() => File.Exists(Path.Combine(context.RootDirectory, "ServiceStack", "ServiceStack.csproj")).Should().BeTrue()); "And the solution file should have the correct name" ._(() => result.Solution.Name.Should().Be("MySolution")); "And it should create a solution file on disk" ._(() => File.Exists(Path.Combine(context.RootDirectory, "Solutions", "MySolution.sln")).Should().BeTrue()) .Teardown(() => context.TearDown()); }
public void build_project_with_name(SolutionBuilderContext context, ISolutionContext result, Project project) { "Given I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "When I call build" ._(() => result = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx").Build()); "It should return the build project" ._(() => { project = result.Solution.Projects.FirstOrDefault(); project.Should().NotBeNull(); }); "And the project should have a name" ._(() => project.Name.Should().Be("FrodoFx")); "And the project should have a path" ._(() => project.Path.Should().Be(Path.Combine(context.RootDirectory, "FrodoFx", "FrodoFx.csproj"))); "And the project file should exist on disk" ._(() => File.Exists(project.Path).Should().BeTrue()); "And the solution context path should be the root directory" ._(() => result.Path.Should().Be(context.RootDirectory)); "And it should create a solution file on disk" ._(() => File.Exists(Path.Combine(context.RootDirectory, "Sally.sln")).Should().BeTrue()) .Teardown(() => context.TearDown()); }
public void patch_solution_assembly_info(ICraneApi craneApi, SolutionBuilderContext context, ISolutionContext solutionContext, Project project, AssemblyInfo updatedInfo, string updatedRawInfo) { "Given I have a crane api" ._(() => craneApi = ServiceLocator.Resolve <CraneApi>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with two projects" ._(() => context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => { item.Title = "Sally"; item.Description = "Next generation web server"; item.Version = new Version(0, 0, 0, 1); item.FileVersion = new Version(0, 0, 0, 2); item.InformationalVersion = "RELEASE"; }) .WithProject(item => item.Name = "BobFx") .WithFile <AssemblyInfo>(item => { item.Title = "Bob"; item.Description = "Old school"; item.Version = new Version(0, 0, 0, 1); item.FileVersion = new Version(0, 0, 0, 2); item.InformationalVersion = "RELEASE"; }).Build()); "And I have got the solution context" ._(() => solutionContext = craneApi.GetSolutionContext(context.RootDirectory)); "When I path the solution assembly info for all projects" ._(() => craneApi.PatchSolutionAssemblyInfo(solutionContext, "1.2.3.4")); "Then file version should be set to 1.2.3.4 in all assembly info files" ._(() => { solutionContext = craneApi.GetSolutionContext(context.RootDirectory); solutionContext.Solution.Projects.All(p => p.AssemblyInfo.FileVersion.ToString() == "1.2.3.4") .Should() .BeTrue(); }); "Then version should be set to 1.2.3.4 in all assembly info files" ._(() => solutionContext.Solution.Projects.All(p => p.AssemblyInfo.Version.ToString() == "1.2.3.4") .Should() .BeTrue()); "Then file informational version should be set to 1.2.3.4" ._(() => solutionContext.Solution.Projects.All(p => p.AssemblyInfo.InformationalVersion.ToString() == "1.2.3.4") .Should() .BeTrue() ).Teardown(() => context.TearDown()); }
public void Assemble_with_a_folder_name_creates_a_build_when_solution_is_a_different_name_and_in_different_location( CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext, SolutionBuilderContext solutionBuilderContext) { "Given I have my own private copy of the crane console" ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>()); "And I have a run context" ._(() => craneRunner = new CraneRunner()); "And I have a project called SolutionInDirectoryProject with no build" ._(() => { solutionBuilderContext = ServiceLocator.Resolve <SolutionBuilderContext>(); solutionBuilderContext .CreateBuilder() .WithSolution(solution => solution.Path = Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "solutions", "MySolution.sln")) .WithFile(file => file.AddSolutionPackagesConfigWithXUnitRunner(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "solutions", ".nuGet", "packages.config"))) .WithProject(project => { project.Name = "ServiceStack"; project.Path = Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "ServiceStack", "ServiceStack.csproj"); }) .Build(); }); "When I run crane assemble SolutionInDirectoryProject" ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane Assemble SolutionInDirectoryProject")); "It should say 'Assemble success.'" ._(() => { result.ErrorOutput.Should().BeEmpty(); result.StandardOutput.Should().Be("Assemble success."); }); "It should create a build.ps1 in the top level folder" ._( () => new DirectoryInfo(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject")).GetFiles() .Count(f => f.Name.ToLower() == "build.ps1") .Should() .Be(1) ); "It should be able to be built successfully with all tests passing" ._(() => { var buildResult = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject")); buildResult.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree(); }); "It should create a build for the project with a reference to the solution file" ._(() => File.ReadAllText(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "build", "default.ps1")).Should().Contain("MySolution.sln")) .Teardown(() => craneTestContext.TearDown()); }
public void Initialize() { this.ctx = new SolutionBuilderContext { UserMessageService = Mock.Of <IUserMessageService>(ums => ums.PromptWarning(It.IsAny <string>()) == true), PatternManager = Mocks.Of <IPatternManager>().First(), ShowProperties = () => { } }; }
public void Initilize() { this.ctx = new SolutionBuilderContext { PatternManager = new Mock <IPatternManager>().Object, NewProductDialogFactory = x => new Mock <IDialogWindow>(x).Object, NewNodeDialogFactory = x => new Mock <IDialogWindow>(x).Object, UserMessageService = new Mock <IUserMessageService>().Object }; }
public void WhenContainerIsNotAutomationContainer_ThenAutomationMenusIsEmpty() { var container = new Mock <IProductElement>(); var ctx = new SolutionBuilderContext { ShowProperties = () => { }, }; var viewModel = new TestProductElementViewModel <IAbstractElement>(container.Object, ctx); Assert.False(viewModel.MenuOptions.OfType <AutomationMenuOptionViewModel>().Any()); }
public void Initialize() { this.element = new Mock <IAbstractElement>(); this.element.As <IProductElement>().Setup(x => x.Info).Returns(Mocks.Of <IPatternElementInfo>().First()); this.element.As <IAbstractElement>().Setup(e => e.Elements).Returns(Enumerable.Empty <IAbstractElement>()); this.context = new SolutionBuilderContext { PatternManager = Mock.Of <IPatternManager>(), ShowProperties = () => { }, UserMessageService = Mock.Of <IUserMessageService>(ums => ums.PromptWarning(It.IsAny <string>()) == true), }; this.target = new TestElementViewModel <IAbstractElement>(this.element.Object, this.context); }
public void build_project_with_assembly_info(SolutionBuilderContext context, ISolutionContext result, Project project, AssemblyInfo assemblyInfo) { "Given I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "When I call build with a solution, a project and an assembly info" ._(() => result = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => { item.Title = "FrodoFx"; item.Description = "Middle earth web server"; item.FileVersion = new Version(0, 0, 1, 2049); item.Version = new Version(0, 0, 1); item.InformationalVersion = "release"; }) .Build()); "It should return the build project with an assembly info" ._(() => { project = result.Solution.Projects.FirstOrDefault(); project.Should().NotBeNull("the project should not be null"); assemblyInfo = project.AssemblyInfo; assemblyInfo.Should().NotBeNull("the assembly info should not be null"); }); "And the assembly info title should be set" ._(() => assemblyInfo.Title.Should().Be("FrodoFx")); "And the assembly info version should be set" ._(() => assemblyInfo.Version.Should().Be(new Version(0, 0, 1))); "And the assembly info file version should be set" ._(() => assemblyInfo.FileVersion.Should().Be(new Version(0, 0, 1, 2049))); "And the assembly informational attribute should be set" ._(() => assemblyInfo.InformationalVersion.Should().Be("release")); "And the assembly info file should exist on disk" ._(() => File.Exists(assemblyInfo.Path).Should().BeTrue(string.Format("assembly info with path: {0} did not exist on disk", assemblyInfo.Path))); "And it should create a solution file on disk" ._(() => File.Exists(Path.Combine(context.RootDirectory, "Sally.sln")).Should().BeTrue()) .Teardown(() => context.TearDown()); }
public void Initialize() { var child1 = Create <ICollection, ICollectionInfo>("Bar1", Cardinality.ZeroToMany); var child2 = Create <IElement, IElementInfo>("Bar2", Cardinality.OneToOne); this.element = Create <IElement, IElementInfo>("Foo1", Cardinality.ZeroToMany, child1, child2); var children = (List <IAbstractElementInfo>) this.element.Info.Elements; children.Add(Mocks.Of <IElementInfo>().First(e => e.Name == "Element 1" && e.DisplayName == "Element 1" && e.IsVisible == true && e.AllowAddNew == true && e.Cardinality == Cardinality.ZeroToMany)); children.Add(Mocks.Of <ICollectionInfo>().First(e => e.Name == "Collection 1" && e.DisplayName == "Collection 1" && e.IsVisible == true && e.AllowAddNew == true && e.Cardinality == Cardinality.ZeroToMany)); var newNodeDialog = new Mock <IDialogWindow>(); newNodeDialog.Setup(x => x.ShowDialog()).Returns(true); var ctx = new SolutionBuilderContext { PatternManager = new Mock <IPatternManager>().Object, UserMessageService = Mock.Of <IUserMessageService>(ums => ums.PromptWarning(It.IsAny <string>()) == true), ShowProperties = () => { }, NewNodeDialogFactory = x => newNodeDialog.Object }; var serviceProvider = Mocks.Of <IServiceProvider>() .First(x => x.GetService(typeof(ISolutionEvents)) == new Mock <ISolutionEvents>().Object); var explorer = new SolutionBuilderViewModel(ctx, serviceProvider); this.target = new ElementViewModel(this.element, ctx); this.target.RenderHierarchyRecursive(); }
public void Initialize() { this.element = new Mock <IProductElement>(); this.element.As <IProductElement>().Setup(x => x.Info).Returns(Mocks.Of <IPatternElementInfo>().First()); this.automation = new Mock <IAutomationExtension>(); this.automation.As <IAutomationMenuCommand>().Setup(m => m.Text).Returns("Foo"); this.automation.As <INotifyPropertyChanged>(); this.automation.As <ICommandStatus>(); this.element.Setup(x => x.AutomationExtensions).Returns(new[] { this.automation.Object }); this.context = new SolutionBuilderContext { PatternManager = Mock.Of <IPatternManager>(), ShowProperties = () => { }, UserMessageService = Mock.Of <IUserMessageService>(ums => ums.PromptWarning(It.IsAny <string>()) == true), }; this.target = new TestProductElementViewModel <IAbstractElement>(this.element.Object, this.context); }
public void Initialize() { var patternManager = new Mock <IPatternManager>(); patternManager.Setup(x => x.InstalledToolkits).Returns(Enumerable.Empty <IInstalledToolkitInfo>()); this.element = Create <IElement, IElementInfo>("Foo", Cardinality.OneToOne); var extensions = (List <IExtensionPointInfo>) this.element.Info.ExtensionPoints; extensions.Add(Mocks.Of <IExtensionPointInfo>().First(x => x.DisplayName == "Foo")); extensions.Add(Mocks.Of <IExtensionPointInfo>().First(x => x.DisplayName == "Bar")); var ctx = new SolutionBuilderContext { PatternManager = patternManager.Object, ShowProperties = () => { } }; this.target = new ElementViewModel(this.element, ctx); }
public void Initialize() { var serviceProvider = GetServiceProvider(); this.patternManager = new Mock <IPatternManager>(); this.patternManager.Setup(p => p.IsOpen).Returns(true); var products = Mocks.Of <IProduct>().Where(p => p.Views == GetViews() && p.CurrentView == GetViews().FirstOrDefault(v => v.Info.IsDefault) && p.InstanceName == Path.GetRandomFileName() && p.Info == new Mock <IPatternInfo>().Object&& p.BeginTransaction() == new Mock <ITransaction>().Object) .Take(2) .ToList(); this.patternManager.Setup(p => p.Products).Returns(products); this.patternManager.Setup(p => p.DeleteProduct(It.IsAny <IProduct>())) .Callback <IProduct>((p) => { products.Remove(p); this.patternManager.Raise(m => m.ElementDeleted += null, new ValueEventArgs <IProductElement>(p)); }) .Returns(true); this.solutionEvents = Mock.Get(serviceProvider.GetService <ISolutionEvents>()); this.solutionEvents.Setup(e => e.IsSolutionOpened).Returns(true); var ctx = new SolutionBuilderContext { PatternManager = this.patternManager.Object, NewProductDialogFactory = x => new Mock <IDialogWindow>().Object, NewNodeDialogFactory = x => new Mock <IDialogWindow>().Object, ShowProperties = () => { }, UserMessageService = new Mock <IUserMessageService>().Object }; this.target = new SolutionBuilderViewModel(ctx, serviceProvider); }
public void Initialize() { var serviceProvider = GetServiceProvider(); IProduct product = null; this.patternManager = new Mock <IPatternManager>(); this.patternManager.Setup(p => p.CreateProduct(It.IsAny <IInstalledToolkitInfo>(), It.IsAny <string>(), true)) .Callback(() => { product = Mocks.Of <IProduct>().First(p => p.Info.Name == "Foo" && p.Views == GetViews() && p.CurrentView == GetViews().FirstOrDefault(v => v.Info.IsDefault) && p.InstanceName == Path.GetRandomFileName()); this.patternManager.Setup(p => p.Products).Returns(new[] { product }); this.patternManager.Raise(p => p.ElementCreated += null, new ValueEventArgs <IProductElement>(product)); this.patternManager.Raise(p => p.ElementInstantiated += null, new ValueEventArgs <IProductElement>(product)); }) .Returns(() => product); var solutionListener = Mock.Get(serviceProvider.GetService <ISolutionEvents>()); solutionListener.Setup(sl => sl.IsSolutionOpened).Returns(true); this.dialog = new Mock <IDialogWindow>(); this.context = new SolutionBuilderContext { PatternManager = patternManager.Object, NewProductDialogFactory = x => this.dialog.Object, NewNodeDialogFactory = x => new Mock <IDialogWindow>().Object, UserMessageService = new Mock <IUserMessageService>().Object, ShowProperties = () => { } }; this.target = new SolutionBuilderViewModel(this.context, serviceProvider); }
public void Get_context_with_root_folder_path_returns_all_projects(ICraneApi craneApi, SolutionBuilderContext context, ISolutionContext result, Project project) { "Given I have a crane api" ._(() => craneApi = ServiceLocator.Resolve <CraneApi>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with two projects" ._(() => context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithProject(item => item.Name = "FrodoFx.UnitTests") .Build()); "When I get the solution context via the api" ._(() => { result = craneApi.GetSolutionContext(context.RootDirectory); }); "And it should return a model representation of the solution on disk" ._(() => result.Solution.Should().NotBeNull()); "And it should have the correct solution name" ._(() => result.Solution.Name.Should().Be("Sally")); "And it should have the correct solution path" ._(() => result.Solution.Path.Should().Be(Path.Combine(context.RootDirectory, "Sally.sln"))); "And it should reference its parent context" ._(() => result.Solution.SolutionContext.Should().NotBeNull()); "And it should have two projects" ._(() => result.Solution.Projects.Count().Should().Be(2)); "And the projects should have the correct name" ._(() => { result.Solution.Projects.Any(item => item.Name.Equals("FrodoFx")).Should().BeTrue(); result.Solution.Projects.Any(item => item.Name.Equals("FrodoFx.UnitTests")).Should().BeTrue(); }); "And the projects should have the correct path" ._(() => { result.Solution.Projects.Any(item => item.Path.Equals(Path.Combine(context.RootDirectory, "FrodoFx", "FrodoFx.csproj"))).Should().BeTrue(); result.Solution.Projects.Any(item => item.Path.Equals(Path.Combine(context.RootDirectory, "FrodoFx.UnitTests", "FrodoFx.UnitTests.csproj"))).Should().BeTrue(); }); "And the projects should reference their solution" ._(() => result.Solution.Projects.All(item => item.Solution != null).Should().BeTrue()) .Teardown(() => context.TearDown()); }
public void map_fubu_project_to_crane_project(IFubuProjectMapper projectMapper, SolutionBuilderContext context, ISolutionContext solutionContext, Project result) { "Given I have a project mapper" ._(() => projectMapper = ServiceLocator.Resolve <IFubuProjectMapper>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with a project" ._(() => solutionContext = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => item.Title = "FrodoFx") .Build()); "When I map the fubu project using the mapper" ._(() => result = projectMapper.Map(FubuCsProjFile.CsProjFile.LoadFrom(solutionContext.Solution.Projects.First().Path))); "It should return a project" ._(() => result.Should().NotBeNull()); "It should map the projects name" ._(() => result.Name.Should().Be("FrodoFx")); "It should map the projects assemblyinfo" ._(() => result.AssemblyInfo.Title.Should().Be("FrodoFx", string.Format("File contents of {0} is {1}.", result.AssemblyInfo.Path, File.ReadAllText(result.AssemblyInfo.Path)))); "It should map the projects path" ._(() => result.Path.Should().Be(Path.Combine(context.RootDirectory, "FrodoFx", "FrodoFx.csproj"))) .Teardown(() => context.TearDown()); }
public void map_fubu_solution_to_crane_solution(IFubuSolutionMapper solutionMapper, SolutionBuilderContext context, ISolutionContext solutionContext, Solution result) { "Given I have a solution mapper" ._(() => solutionMapper = ServiceLocator.Resolve <IFubuSolutionMapper>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with two projects" ._(() => solutionContext = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithProject(item => item.Name = "FrodoFx.UnitTests") .Build()); "When I map the fubu solution" ._(() => result = solutionMapper.Map(FubuCsProjFile.Solution.LoadFrom(solutionContext.Solution.Path))); "It should return a solution" ._(() => result.Should().NotBeNull()); "It should map the solutions name" ._(() => result.Name.Should().Be("Sally")); "It should map the solutions path" ._(() => result.Path.Should().Be(Path.Combine(context.RootDirectory, "Sally.sln"))); "It should map the solutions projects" ._(() => result.Projects.Count().Should().Be(2)); "It should map the solutions projects that reference their parent solution" ._(() => result.Projects.All(item => item.Solution.Equals(result)).Should().BeTrue()) .Teardown(() => context.TearDown()); }
public TestElementViewModel(IAbstractElement element, SolutionBuilderContext context) : base(element, context) { }
public TestProductElementViewModel(IProductElement element, SolutionBuilderContext context) : base(element, context) { }
public void patch_solution_assembly_info_when_project_in_git(ICraneApi craneApi, SolutionBuilderContext context, ISolutionContext solutionContext, Project project, AssemblyInfo updatedInfo, string updatedRawInfo, Git git) { "Given I have a crane api" ._(() => craneApi = ServiceLocator.Resolve <CraneApi>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with two projects" ._(() => context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => { item.Title = "Sally"; item.Description = "Next generation web server"; item.Version = new Version(0, 0, 0, 1); item.FileVersion = new Version(0, 0, 0, 2); item.InformationalVersion = "RELEASE"; }) .WithProject(item => item.Name = "BobFx") .WithFile <AssemblyInfo>(item => { item.Title = "Bob"; item.Description = "Old school"; item.Version = new Version(0, 0, 0, 1); item.FileVersion = new Version(0, 0, 0, 2); item.InformationalVersion = "RELEASE"; }).Build()); "And I have got the solution context" ._(() => solutionContext = craneApi.GetSolutionContext(context.RootDirectory)); "And I initialize that as a git repository" ._(() => { git = ServiceLocator.Resolve <Git>(); git.Run("init", context.RootDirectory).ErrorOutput.Should().BeEmpty(); git.Run("config user.email [email protected]", context.RootDirectory).ErrorOutput.Should().BeEmpty(); }); "And I have a previous commit" ._(() => { git.Run("add -A", context.RootDirectory).ErrorOutput.Should().BeEmpty(); git.Run("config user.email [email protected]", context.RootDirectory).ErrorOutput.Should().BeEmpty(); git.Run("commit -m \"My brand new project\"", context.RootDirectory).ErrorOutput.Should().BeEmpty(); }); "When I path the solution assembly info for all projects" ._(() => craneApi.PatchSolutionAssemblyInfo(solutionContext, "1.2.3.4")); "Then file version should be set to 1.2.3.4 in all assembly info files" ._(() => { solutionContext = craneApi.GetSolutionContext(context.RootDirectory); solutionContext.Solution.Projects.All(p => p.AssemblyInfo.FileVersion.ToString() == "1.2.3.4") .Should() .BeTrue(); }); "Then version should be set to 1.2.3.4 in all assembly info files" ._(() => solutionContext.Solution.Projects.All(p => p.AssemblyInfo.Version.ToString() == "1.2.3.4") .Should() .BeTrue()); "Then file informational version should start with 1.2.3.4" ._(() => solutionContext.Solution.Projects.All(p => p.AssemblyInfo.InformationalVersion.ToString().StartsWith("1.2.3.4")) .Should() .BeTrue()) .Teardown(() => context.TearDown()); "Then file informational version should end with the commit message 'My brand new project'" ._(() => solutionContext.Solution.Projects.All(p => p.AssemblyInfo.InformationalVersion.ToString().EndsWith("My brand new project")) .Should() .BeTrue()) .Teardown(() => context.TearDown()); }
public void patch_assembly_info(ICraneApi craneApi, SolutionBuilderContext context, ISolutionContext solutionContext, Project project, AssemblyInfo updatedInfo, string updatedRawInfo) { "Given I have a crane api" ._(() => craneApi = ServiceLocator.Resolve <CraneApi>()); "And I have a solution builder context" ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>()); "And I have a solution with a project and an assembly info file" ._(() => solutionContext = context.CreateBuilder() .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln")) .WithProject(item => item.Name = "FrodoFx") .WithFile <AssemblyInfo>(item => { item.Title = "Sally"; item.Description = "Next generation web server"; item.Version = new Version(0, 0, 0, 1); item.FileVersion = new Version(0, 0, 0, 2); item.InformationalVersion = "RELEASE"; }).Build()); "And I have an updated assembly info with different version, file number and informational attribute" ._(() => { updatedInfo = solutionContext.Solution.Projects.First().AssemblyInfo; updatedInfo.Version = new Version(0, 1, 0, 0); updatedInfo.FileVersion = new Version(0, 1, 20); updatedInfo.InformationalVersion = "DEBUG"; }); "When I patch the assemble info" ._(() => { craneApi.PatchAssemblyInfo(updatedInfo); solutionContext = craneApi.GetSolutionContext(solutionContext.Path); // reload to get updated model project = solutionContext.Solution.Projects.First(); updatedRawInfo = File.ReadAllText(project.AssemblyInfo.Path); }); "Then it should update the assembly file version" ._(() => { updatedRawInfo.Should().Contain("[assembly: AssemblyFileVersionAttribute(\"0.1.20\")]"); project.AssemblyInfo.FileVersion.Should().Be(new Version(0, 1, 20)); }); "Then it should update the informational version attribute" ._(() => { updatedRawInfo.Should().Contain("[assembly: AssemblyInformationalVersionAttribute(\"DEBUG\")]"); project.AssemblyInfo.InformationalVersion.Should().Be("DEBUG"); }); "Then it should update the assembly version" ._(() => { updatedRawInfo.Should().Contain("[assembly: AssemblyVersionAttribute(\"0.1.0.0\")]"); project.AssemblyInfo.Version.Should().Be(new Version(0, 1, 0, 0)); }); "Then it not update the assembly title as it was not changed" ._(() => { updatedRawInfo.Should().Contain("[assembly: AssemblyTitleAttribute(\"Sally\")]"); project.AssemblyInfo.Title.Should().Be("Sally"); }) .Teardown(() => context.TearDown()); }
public void Initialize() { var hiddenView = CreateView("HiddenView", false); Mock.Get(hiddenView.Info).Setup(x => x.IsVisible).Returns(false); var views = new[] { CreateView("View1", false, Create <IElement, IElementInfo>("Element1", Cardinality.OneToOne)), CreateView("View2", true, Create <ICollection, ICollectionInfo>("Collection2", Cardinality.OneToOne), Create <IElement, IElementInfo>("Element2", Cardinality.ZeroToMany)), hiddenView, }; var view1Children = (List <IAbstractElementInfo>)views[0].Info.Elements; Mock.Get((IElementInfo)view1Children[0]) .Setup(e => e.Parent) .Returns(views[0].Info); var view2Children = (List <IAbstractElementInfo>)views[1].Info.Elements; Mock.Get((ICollectionInfo)view2Children[0]) .Setup(e => e.Parent) .Returns(views[1].Info); Mock.Get((IElementInfo)view2Children[1]) .Setup(e => e.Parent) .Returns(views[1].Info); view2Children.Add(Mocks.Of <IElementInfo>().First(e => e.Name == "Foo1" && e.IsVisible == true && e.AllowAddNew == true && e.DisplayName == "Foo1" && e.Cardinality == Cardinality.ZeroToMany)); view2Children.Add(Mocks.Of <ICollectionInfo>().First(e => e.Name == "Foo2" && e.IsVisible == true && e.AllowAddNew == true && e.DisplayName == "Foo2" && e.Cardinality == Cardinality.ZeroToMany)); this.product = Mocks.Of <IProduct>().First(p => p.InstanceName == "Foo" && p.Views == views && p.CurrentView == views.FirstOrDefault(v => v.Info.IsDefault) && p.Info == new Mock <IPatternInfo>().Object); this.patternManager = Mocks.Of <IPatternManager>() .First(x => x.InstalledToolkits == Enumerable.Empty <IInstalledToolkitInfo>()); var newNodeDialog = new Mock <IDialogWindow>(); newNodeDialog.Setup(x => x.ShowDialog()).Returns(true); this.context = new SolutionBuilderContext { PatternManager = this.patternManager, UserMessageService = Mock.Of <IUserMessageService>(ums => ums.PromptWarning(It.IsAny <string>()) == true), ShowProperties = () => { }, NewNodeDialogFactory = x => newNodeDialog.Object, }; var serviceProvider = Mocks.Of <IServiceProvider>() .First(x => x.GetService(typeof(ISolutionEvents)) == new Mock <ISolutionEvents>().Object); var explorer = new SolutionBuilderViewModel(context, serviceProvider); this.target = new ProductViewModel(this.product, context); this.target.RenderHierarchyRecursive(); }