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);
        }
예제 #2
0
파일: ProjectHelper.cs 프로젝트: rhwy/Enlil
        private BuildServices setupServices()
        {
            var services = new BuildServices();
            var setter   = new ConventionsSetter();

            conventions(setter);
            setter.SetupServices(services);
            return(services);
        }
예제 #3
0
    // 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);
    }
예제 #4
0
    // 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);
    }
예제 #5
0
    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);
    }
예제 #6
0
    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);
    }
예제 #7
0
    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);
    }
예제 #8
0
    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);
    }
예제 #9
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);
    }
예제 #10
0
파일: ProjectHelper.cs 프로젝트: rhwy/Enlil
        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);
        }
예제 #11
0
    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);
    }
예제 #12
0
    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)));
    }
예제 #13
0
    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);
        }
예제 #15
0
    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);
    }
예제 #16
0
 bool BeforeDistributeEvent(WrenchProject proj, BuildServices bs)
 {
     Console.WriteLine(" + {0}", bs.FullName);
     numdisted++;
     return(false);
 }
예제 #17
0
 bool BeforeInstallEvent(WrenchProject proj, BuildServices bs)
 {
     Console.WriteLine(" + {0}", bs.FullName);
     numinstalled++;
     return(false);
 }
예제 #18
0
 bool PrintOperation(WrenchProject proj, BuildServices bs)
 {
     Console.WriteLine("{0}", bs.FullName);
     return(false);
 }
예제 #19
0
    // WrenchOperations events

    bool BeforeBuildEvent(WrenchProject proj, BuildServices bs)
    {
        Console.WriteLine("Building `{0}\' ...", bs.FullName);
        numbuilt++;
        return(false);
    }
예제 #20
0
 bool BeforeSkipEvent(WrenchProject proj, BuildServices bs)
 {
     numskipped++;
     return(false);
 }
예제 #21
0
파일: Program.cs 프로젝트: das953/sharpness
 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");
 }
예제 #22
0
 internal void SetupServices(BuildServices services)
 {
     services.ProjectFileChooser  = projectFileChooser ?? new DirectoryProjectFileChooser();
     services.ProjectBuilder      = projectBuilder ?? new MsBuildProjectBuilder();
     services.ProjectBinaryLoader = projectBinaryLoader ?? new AssemblyBinaryLoader();
 }