public void GetAllBuild_WhenCalled_CorrectListBuildIsReturn_Test() { ///Arrange var fakeBuilds = new[] { new Build { BuildNumber = "123", Name = "foo" }, new Build { BuildNumber = "124", Name = "foa" } }; var buildRepositoryMoq = new Moq.Mock <IBuildRepository>(); buildRepositoryMoq.Setup(x => x.GetAll()) .Returns(fakeBuilds); var buildServices = new BuildServices(buildRepositoryMoq.Object); ///Act var buildDtoList = buildServices.GetBuilds(); ///Assert Assert.IsNotNull(buildDtoList); Assert.IsInstanceOfType(buildDtoList, typeof(List <BuildDto>)); Assert.AreEqual(buildDtoList.Count(), 2); }
private BuildServices setupServices() { var services = new BuildServices(); var setter = new ConventionsSetter(); conventions(setter); setter.SetupServices(services); return(services); }
// Config bool ConfigOperation(WrenchProject proj, BuildServices bs) { Result res = bs.GetValue().Result; if (res == null) { return(true); } // prompt Result rprompt; if (bs.GetTag("prompt", out rprompt)) { return(true); } string prompt; if (rprompt == null) { log.PushLocation(bs.FullName); log.Warning(2017, "This configurable option does not have a \'prompt\' tag.", null); log.PopLocation(); prompt = String.Format("Set value of {0}:", bs.FullName); } else { // TODO: i18n prompt = ((MBString)rprompt).Value; } if (res is MBBool) { DoConfigBool(prompt, (MBBool)res); } else if (res is MBString) { DoConfigString(prompt, (MBString)res); } else if (res is MBDirectory) { DoConfigDirectory(prompt, (MBDirectory)res); } else { string s = String.Format("Current value is {0}", res); log.PushLocation(bs.FullName); log.Error(2018, "Don't know how to configure this option.", s); log.PopLocation(); return(true); } bs.FixValue(res); return(false); }
// Callbacks void OnBoolToggled(object sender, EventArgs args) { CheckButton cb = (CheckButton)sender; BuildServices services = (BuildServices)cb.Data[services_key]; MBBool val = (MBBool)cb.Data[result_key]; val.Value = cb.Active; Console.WriteLine("Fixing {0} = {1}", services.FullName, val); services.FixValue(val); }
void OnStringTimeout(Entry entry) { BuildServices services = (BuildServices)entry.Data[services_key]; MBString val = (MBString)entry.Data[result_key]; val.Value = entry.Text; Console.WriteLine("Fixing {0} = {1}", services.FullName, val); services.FixValue(val); timeouts.Remove(entry); }
Widget MakeBoolItem(BuildServices services, string prompt, MBBool res) { CheckButton cb = new CheckButton(prompt); cb.Active = res.Value; cb.Data[result_key] = res; cb.Data[services_key] = services; cb.Toggled += new EventHandler(OnBoolToggled); return(cb); }
bool ExportAsXml(WrenchProject proj, BuildServices bs) { Result r = WrenchOperations.BuildValue(proj, bs).Result; if (r == null) { return(true); } r.ExportXml(export_writer, bs.FullName); return(false); }
public int ImportXml(string here, ProjectManager pm) { int num_imported = 0; while (!import_reader.EOF) { if (import_reader.NodeType != XmlNodeType.Element || import_reader.Name != "result") { import_reader.Read(); continue; } string id; Result r = Result.ImportXml(import_reader, out id, log); if (r == null) { continue; } if (id == null || id.Length == 0) { log.Warning(3019, "Found a result without associated ID; don't know where to import", r.ToString()); continue; } if (id[0] != '/') { log.Warning(3019, "This file configures a relative target name; " + "behavior will vary depending on current directory", null); id = here + id; } BuildServices bs = pm.Project.GetTargetServices(id); if (bs == null) { continue; } Console.WriteLine(" + {0} = {1}", id, r); bs.FixValue(r); num_imported++; } Console.WriteLine("Imported {0} result values", num_imported); return(0); }
// basic operations bool ShowOperation(WrenchProject proj, BuildServices bs) { Result res = bs.GetValue().Result; if (res != null) { Console.WriteLine("{0} = {1}", bs.FullName, res); } else { Console.WriteLine("{0} couldn't be evaluated.", bs.FullName); } return(false); }
private BuildContext buildAndGetAssembly(BuildServices services, BuildContext context) { try { context = services.ProjectFileChooser.FindProjectFile(context); context = services.ProjectBuilder.BuildProject(context); context = services.ProjectBinaryLoader.LoadAssemblyAndContext(context); } catch (Exception e) { context.Error = e; } return(context); }
bool DescribeInstall(WrenchProject proj, BuildServices bs) { IResultInstaller iri; Result res; if (WrenchOperations.GetInstallerAndResult(proj, bs, out iri, out res)) { return(true); } if (iri == null) { return(false); } Console.WriteLine(" + {0}", iri.DescribeAction(res, bs.Context)); return(false); }
bool DoRemoteInstall(WrenchProject proj, BuildServices bs) { IResultInstaller iri; Result res; if (WrenchOperations.GetInstallerAndResult(proj, bs, out iri, out res)) { return(true); } if (iri == null) { return(false); } bs.Logger.Log("operation.install", bs.FullName); Console.WriteLine(" + {0}", bs.FullName); return(install_svc.Install((Result)iri, res, install_is_uninstall, new BuildContextProxy(bs.Context))); }
Widget MakeStringItem(BuildServices services, string prompt, MBString res) { HBox box = new HBox(); box.Show(); Label label = new Label(prompt); label.Show(); label.Xalign = 1.0F; Entry entry = new Entry(res.Value); entry.Show(); entry.Data[result_key] = res; entry.Data[services_key] = services; entry.Changed += new EventHandler(OnStringChanged); box.PackStart(label, true, true, 2); box.PackStart(entry, false, true, 2); return(box); }
public void GetBuild_WhenCalled_CorrectBuildIsReturn_Test() { ///Arrange var fakeBuild = new Build { BuildNumber = "123", Name = "foo" }; var buildRepositoryMoq = new Moq.Mock <IBuildRepository>(); buildRepositoryMoq.Setup(x => x.Find(It.IsAny <Expression <Func <Build, bool> > >(), null)) .Returns(fakeBuild); var buildServices = new BuildServices(buildRepositoryMoq.Object); ///Act var buildDto = buildServices.GetBuild("foo"); ///Assert Assert.IsNotNull(buildDto); Assert.IsInstanceOfType(buildDto, typeof(BuildDto)); Assert.AreEqual(buildDto.BuildNumber, fakeBuild.BuildNumber); Assert.AreEqual(buildDto.Name, fakeBuild.Name); }
bool LoadConfigItem(WrenchProject proj, BuildServices bs) { string prompt, group; string target = bs.FullName; Result res = bs.GetValue().Result; if (res == null) { return(true); } Result tag; if (bs.GetTag("prompt", out tag)) { return(true); } MBString rstr = tag as MBString; if (rstr == null) { // FIXME Console.Error.WriteLine("Configurable option " + target + " does not have a string \'prompt\' tag."); prompt = target; } else { // TODO: i18n prompt = rstr.Value; } if (bs.GetTag("config_group", out tag)) { return(true); } rstr = tag as MBString; if (rstr == null) { group = DefaultGroupName; } else { // TODO: i18n group = rstr.Value; } Widget widget = null; if (res is MBBool) { widget = MakeBoolItem(bs, prompt, (MBBool)res); } else if (res is MBString) { widget = MakeStringItem(bs, prompt, (MBString)res); } else { // FIXME Console.Error.WriteLine("Don't know how to configure the option {0}.", target); return(true); } AddGuiItem(group, widget); return(false); }
bool BeforeDistributeEvent(WrenchProject proj, BuildServices bs) { Console.WriteLine(" + {0}", bs.FullName); numdisted++; return(false); }
bool BeforeInstallEvent(WrenchProject proj, BuildServices bs) { Console.WriteLine(" + {0}", bs.FullName); numinstalled++; return(false); }
bool PrintOperation(WrenchProject proj, BuildServices bs) { Console.WriteLine("{0}", bs.FullName); return(false); }
// WrenchOperations events bool BeforeBuildEvent(WrenchProject proj, BuildServices bs) { Console.WriteLine("Building `{0}\' ...", bs.FullName); numbuilt++; return(false); }
bool BeforeSkipEvent(WrenchProject proj, BuildServices bs) { numskipped++; return(false); }
static void TestBuild() { Debug.Assert(BuildServices.Resolve <DirectoryService>() != null, "Unable to find DirectoryService"); Debug.Assert(BuildServices.Resolve <GitService>() != null, "Unable to find GitService"); Debug.Assert(BuildServices.Resolve <GitService>().Branch == "master", "Unable to find a branch"); }
internal void SetupServices(BuildServices services) { services.ProjectFileChooser = projectFileChooser ?? new DirectoryProjectFileChooser(); services.ProjectBuilder = projectBuilder ?? new MsBuildProjectBuilder(); services.ProjectBinaryLoader = projectBinaryLoader ?? new AssemblyBinaryLoader(); }