Beispiel #1
0
 public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     SsoClientCredentials cred = bindingParameters.Find<SsoClientCredentials>();
     if (cred == null) throw new ConfigurationErrorsException("The session behavior must be used in conjunction with SsoClientCredentials");
     cred.Session = session;
     cred.Duration = duration;
     cred.Cache = cache;
     cred.Config = config;
 }
Beispiel #2
0
        static int Run(string[] args)
        {
            if (args.Length == 0)
                throw new ApplicationException("Missing command.");

            var commands = new[] 
            {
                new Func<ICommand>(() => new SelectCommand()).AsKeyTo(Aliases("select", "sel")),
                new Func<ICommand>(() => new ExplainCommand()).AsKeyTo(Aliases("explain", "describe", "desc")),
            }
            .SelectMany(e => e.Value.Select(v => v.AsKeyTo(e.Key)))
            .ToDictionary(e => e.Key, e => e.Value);

            var name = args[0];
            
            var command = commands.Find(name);
            if (command == null)
                throw new ApplicationException("Invalid command.");

            return command().Run(args.Skip(1).ToArray());           
        }
Beispiel #3
0
        public static Mock<ITestLinkExtra> _getTestLinkMockWithTestCases(
           System.Collections.Generic.List<Meyn.TestLink.TestProject> listOfProjects,
           System.Collections.Generic.List<Meyn.TestLink.TestPlan> listOfTestPlans,
           System.Collections.Generic.List<Meyn.TestLink.TestPlatform> listOfTestPlatforms,
           System.Collections.Generic.List<Meyn.TestLink.TestPlanTotal> listOfTestPlanTotals,
           System.Collections.Generic.List<Meyn.TestLink.Build> listOfBuilds,
           System.Collections.Generic.List<Meyn.TestLink.TestSuite> listOfTestSuites,
           System.Collections.Generic.List<Meyn.TestLink.TestCase> listOfTestCases)
        {
            var testLinkMock = _getTestLinkMockWithTestSuites(listOfProjects, listOfTestPlans, listOfTestPlatforms, listOfTestPlanTotals, listOfBuilds, listOfTestSuites);

            //testLinkMock.Setup(t => t.CreateTestCase

            testLinkMock.Setup(t => t.GetTestCase(It.IsAny<int>(), It.IsAny<int>()))
                .Returns((int tcId, int verId) => listOfTestCases.Find(testCase => testCase.id == tcId && testCase.version == verId));

            //testLinkMock.Setup(t => t.GetTestCaseAttachments

            //testLinkMock.Setup(t => t.GetTestCaseIDByName

            //testLinkMock.Setup(t => t.GetTestCaseIdsForTestSuite

            //            System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestPlan> listOfTestCasesFromTestPlan =
            //                new System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestPlan>();
            //            foreach (Meyn.TestLink.TestCase testCase in listOfTestCases) {
            //                listOfTestCasesFromTestPlan.Add(testCase);
            //            }
            //            testLinkMock.Setup(t => t.GetTestCasesForTestPlan(It.IsAny<int>()))
            //                //.Returns((int tPlanId) => listOfTestCases.FindAll(testCase => testCase.
            //                .Returns(() => listOfTestCasesFromTestPlan); // there is no relation between test case and test plan id
            //
            //            System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestSuite> listOfTestCasesFromTestSuite =
            //                new System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestSuite>();
            //            foreach (Meyn.TestLink.TestCase testCase in listOfTestCases) {
            //                listOfTestCasesFromTestSuite.Add((Meyn.TestLink.TestCaseFromTestSuite)testCase);
            //            }
            //            testLinkMock.Setup(t => t.GetTestCasesForTestSuite(It.IsAny<int>(), It.IsAny<bool>()))
            //                .Returns((int tsId, bool deep) => listOfTestCasesFromTestSuite.FindAll(testCase => testCase.testsuite_id == tsId)); // deep is ignored

            //testLinkMock.Setup(t => t.UploadTestCaseAttachment

            return testLinkMock;
        }
Beispiel #4
0
        public static Mock<ITestLinkExtra> _getTestLinkMockWithProjects(
           System.Collections.Generic.List<Meyn.TestLink.TestProject> listOfProjects)
        {
            var testLinkMock = _getTestLinkMock();

            testLinkMock.Setup(t => t.GetProjects()).Returns(listOfProjects);
            testLinkMock.Setup(t => t.GetProject(It.IsAny<string>())).Returns((string s) => listOfProjects.Find(item => item.name == s));
            // 20130202
            // testLinkMock.Setup(t => t.GetProjects()).Returns((string id) => listOfProjects);

            return testLinkMock;
        }
Beispiel #5
0
        public static Mock<ITestLinkExtra> _getTestLinkMockWithBuilds(
           System.Collections.Generic.List<Meyn.TestLink.TestProject> listOfProjects,
           System.Collections.Generic.List<Meyn.TestLink.TestPlan> listOfTestPlans,
           System.Collections.Generic.List<Meyn.TestLink.TestPlatform> listOfTestPlatforms,
           System.Collections.Generic.List<Meyn.TestLink.TestPlanTotal> listOfTestPlanTotals,
           System.Collections.Generic.List<Meyn.TestLink.Build> listOfBuilds)
        {
            var testLinkMock = _getTestLinkMockWithTestPlans(listOfProjects, listOfTestPlans, listOfTestPlatforms, listOfTestPlanTotals);

            testLinkMock.Setup(t => t.GetBuildsForTestPlan(It.IsAny<int>()))
                .Returns((int tPlanId) => listOfBuilds.FindAll(build => build.testplan_id == tPlanId));

            testLinkMock.Setup(t => t.GetLatestBuildForTestPlan(It.IsAny<int>()))
                .Returns((int tplanid) => listOfBuilds.Find(build => build.testplan_id == tplanid)); //there's no date for a build

            return testLinkMock;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="adapter"></param>
 /// <returns></returns>
 // ReSharper disable SuggestBaseTypeForParameter
 private static Node GetNode(System.Collections.Generic.List<Node> nodes, ComponentAdapter adapter)
 // ReSharper restore SuggestBaseTypeForParameter
 {
     return nodes.Find(delegate(Node node)
     {
         return node.Adapter == adapter;
     });
 }
Beispiel #7
0
        public void UpdateControls(System.Windows.Forms.Control.ControlCollection ctrlCollection, string formName)
        {
            // Set the row filter based on the Form's name and the lang...
            _appResources.DefaultView.RowFilter = "sys_lang_id=" + _lang.ToString() + " AND form_name='" + formName + "'";
            // If this is the client window - change the title bar...
            //if (ctrlCollection.Owner.GetType() == typeof(GRINGlobal.Client.CuratorTool.GRINGlobalClientCuratorTool))
            //if (ctrlCollection.Owner.GetType().FullName == "GRINGlobal.Client.CuratorTool.GRINGlobalClientCuratorTool")
            {
                //this.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                DataRow[] title = _appResources.DefaultView.ToTable().Select("app_resource_name='Text'");
                if (title != null &&
                    title.Length > 0)
                {
                    if (title[0].Table.Columns.Contains("display_member"))
                    {
                        if (title[0]["display_member"].ToString().Contains("{0}"))
                        {
                            ctrlCollection.Owner.Text = string.Format(title[0]["display_member"].ToString(), System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
                        }
                        else
                        {
                            ctrlCollection.Owner.Text = title[0]["display_member"].ToString() + " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                        }
                    }
                    else if (!ctrlCollection.Owner.Text.Contains(System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()))
                    {
                        ctrlCollection.Owner.Text += " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                    }
                }
                else
                {
                    if (!ctrlCollection.Owner.Text.Contains(System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()))
                    {
                        ctrlCollection.Owner.Text = "GRIN-Global  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                    }
                }
            }

            // Iterate through the Form's controls...
            foreach (DataRowView drv in _appResources.DefaultView)
            {
                System.Windows.Forms.Control[] ctrlArray = ctrlCollection.Find(drv["app_resource_name"].ToString(), true);
                if (ctrlArray != null && ctrlArray.Length > 0)
                {
                    foreach (System.Windows.Forms.Control ctrl in ctrlArray)
                    {
                        ctrl.Text = drv["display_member"].ToString();
                    }
                }
            }

            // Iterate through the Form's toolstrips...
            foreach (System.Windows.Forms.Control ctrl in ctrlCollection)
            {
                if (ctrl is System.Windows.Forms.ToolStrip)
                {
                    System.Windows.Forms.ToolStrip ts = (System.Windows.Forms.ToolStrip)ctrl;
                    foreach (DataRowView drv in _appResources.DefaultView)
                    {
                        System.Windows.Forms.ToolStripItem[] tsiArray = ts.Items.Find(drv["app_resource_name"].ToString(), true);
                        if (tsiArray != null && tsiArray.Length > 0)
                        {
                            foreach (System.Windows.Forms.ToolStripItem tsi in tsiArray)
                            {
                                tsi.Text = drv["display_member"].ToString();
                            }
                        }
                    }
                }
            }
        }
		internal void RestarDescuentosAImpuestosGlobales(System.Collections.Generic.List<FeaEntidades.InterFacturas.resumenImpuestos> impuestos)
		{
			descuentos = ((System.Collections.Generic.List<FeaEntidades.InterFacturas.resumenDescuentos>)ViewState["descuentos"]);
			
			System.Collections.Generic.List<FeaEntidades.IVA.IVA> listaIVA = FeaEntidades.IVA.IVA.ListaMinima();
			double[] impivas = new double[listaIVA.Count];
			for (int i = 0; i < descuentos.Count; i++)
			{
				if (descuentos[i].importe_iva_descuento != 0)
				{
					if (descuentos[i].alicuota_iva_descuentoSpecified)
					{
						FeaEntidades.IVA.IVA auxIVA=listaIVA.Find(delegate(FeaEntidades.IVA.IVA e)
						{
							return e.Codigo == descuentos[i].alicuota_iva_descuento;
						});
						FeaEntidades.InterFacturas.resumenImpuestos ri = impuestos.Find(delegate(FeaEntidades.InterFacturas.resumenImpuestos r)
						{
							return auxIVA.Codigo == r.porcentaje_impuesto;
						});
						if (ri != null)
						{
							ri.importe_impuesto -= descuentos[i].importe_iva_descuento;
						}
						else
						{
							ScriptManager.RegisterStartupScript(this.Parent.Page, GetType(), "Message", Funciones.TextoScript("La alícuota de IVA de un descuento (" + auxIVA.Codigo + ") no coincide con ninguna alícuota de los impuestos"), false);
						}
					}
				}
			}
		}
 /// <summary>
 /// Generates a verification URL
 /// </summary>
 /// <param name="Pairs">The individual attribute pairs</param>
 /// <returns>The appropriate verification URL</returns>
 protected virtual string GenerateVerificationUrl(System.Collections.Generic.List<System.Tuple<string, string>> Pairs)
 {
     if (Pairs.FirstOrDefault(x => x.Item1.Equals("openid.mode",StringComparison.CurrentCultureIgnoreCase)) != null)
         Pairs.Remove(Pairs.FirstOrDefault(x => x.Item1.Equals("openid.mode", StringComparison.CurrentCultureIgnoreCase)));
     Pairs.Add(new System.Tuple<string, string>("openid.mode", "check_authentication"));
     StringBuilder Builder = new StringBuilder();
     Builder.Append(Pairs.Find(x => x.Item1.Equals("openid.op_endpoint", StringComparison.CurrentCultureIgnoreCase)).Item2);
     string Splitter = "?";
     foreach (System.Tuple<string, string> Pair in Pairs)
     {
         Builder.Append(Splitter).Append(Pair.Item1).Append("=").Append(Pair.Item2);
         Splitter = "&";
     }
     return Builder.ToString();
 }
		public void FindThrowsArgumentNullExceptionIfConditionIsNull()
		{
			var dummySource = new[] { 1, 2, 3 };
			Expression<Func<int, bool>> condition = null;
			// ReSharper disable once ExpressionIsAlwaysNull
			var ex = TestUtils.ExpectException<ArgumentNullException>(() => dummySource.Find(condition));
			Assert.AreEqual("condition", ex.ParamName, "ParamName");
		}
        /// <summary>
        /// Verifies the attributes
        /// </summary>
        /// <param name="URL">URL</param>
        /// <param name="Pairs">Data tuple</param>
        /// <returns>True if it is verified, false otherwise</returns>
        public virtual bool Verify(string URL, System.Collections.Generic.List<System.Tuple<string, string>> Pairs)
        {
            System.Tuple<string, string> Pair = Pairs.Find(x => x.Item2 == "http://openid.net/srv/ax/1.0");
            if (Pair == null && Required != Attributes.None)
                return false;
            else if (Pair == null)
                return true;
            string[] Splitter = { "." };
            string Extension = Pair.Item1.Split(Splitter, StringSplitOptions.None)[2];

            if ((Required & Attributes.Address) == Attributes.Address)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.address") == null)
                    return false;
            }
            if ((Required & Attributes.BirthDate) == Attributes.BirthDate)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.birthdate") == null)
                    return false;
            }
            if ((Required & Attributes.CompanyName) == Attributes.CompanyName)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.companyname") == null)
                    return false;
            }
            if ((Required & Attributes.Country) == Attributes.Country)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.country") == null)
                    return false;
            }
            if ((Required & Attributes.Email) == Attributes.Email)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.email") == null)
                    return false;
            }
            if ((Required & Attributes.FirstName) == Attributes.FirstName)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.firstname") == null)
                    return false;
            }
            if ((Required & Attributes.FullName) == Attributes.FullName)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.fullname") == null)
                    return false;
            }
            if ((Required & Attributes.Gender) == Attributes.Gender)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.gender") == null)
                    return false;
            }
            if ((Required & Attributes.JobTitle) == Attributes.JobTitle)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.jobtitle") == null)
                    return false;
            }
            if ((Required & Attributes.Language) == Attributes.Language)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.language") == null)
                    return false;
            }
            if ((Required & Attributes.LastName) == Attributes.LastName)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.lastname") == null)
                    return false;
            }
            if ((Required & Attributes.Phone) == Attributes.Phone)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.phone") == null)
                    return false;
            }
            if ((Required & Attributes.PostalCode) == Attributes.PostalCode)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.postalcode") == null)
                    return false;
            }
            if ((Required & Attributes.TimeZone) == Attributes.TimeZone)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.timezone") == null)
                    return false;
            }
            if ((Required & Attributes.UserName) == Attributes.UserName)
            {
                if (Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.username") == null)
                    return false;
            }
            return true;
        }
        /// <summary>
        /// Gets a dictionary with the requested values
        /// </summary>
        /// <param name="Pairs">Returned attribute pairs</param>
        /// <returns>A dictionary with the requested values</returns>
        public virtual Dictionary<Attributes, string> GetValues(System.Collections.Generic.List<System.Tuple<string, string>> Pairs)
        {
            Dictionary<Attributes, string> ReturnValues = new Dictionary<Attributes, string>();
            System.Tuple<string, string> Pair = Pairs.Find(x => x.Item2 == "http://openid.net/srv/ax/1.0");
            string[] Splitter = { "." };
            string Extension = Pair.Item1.Split(Splitter, StringSplitOptions.None)[2];

            if ((Required & Attributes.Address) == Attributes.Address)
            {
                ReturnValues.Add(Attributes.Address, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.address").Item2);
            }
            if ((Required & Attributes.BirthDate) == Attributes.BirthDate)
            {
                ReturnValues.Add(Attributes.BirthDate, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.birthdate").Item2);
            }
            if ((Required & Attributes.CompanyName) == Attributes.CompanyName)
            {
                ReturnValues.Add(Attributes.CompanyName, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.companyname").Item2);
            }
            if ((Required & Attributes.Country) == Attributes.Country)
            {
                ReturnValues.Add(Attributes.Country, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.country").Item2);
            }
            if ((Required & Attributes.Email) == Attributes.Email)
            {
                ReturnValues.Add(Attributes.Email, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.email").Item2);
            }
            if ((Required & Attributes.FirstName) == Attributes.FirstName)
            {
                ReturnValues.Add(Attributes.FirstName, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.firstname").Item2);
            }
            if ((Required & Attributes.FullName) == Attributes.FullName)
            {
                ReturnValues.Add(Attributes.FullName, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.fullname").Item2);
            }
            if ((Required & Attributes.Gender) == Attributes.Gender)
            {
                ReturnValues.Add(Attributes.Gender, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.gender").Item2);
            }
            if ((Required & Attributes.JobTitle) == Attributes.JobTitle)
            {
                ReturnValues.Add(Attributes.JobTitle, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.jobtitle").Item2);
            }
            if ((Required & Attributes.Language) == Attributes.Language)
            {
                ReturnValues.Add(Attributes.Language, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.language").Item2);
            }
            if ((Required & Attributes.LastName) == Attributes.LastName)
            {
                ReturnValues.Add(Attributes.LastName, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.lastname").Item2);
            }
            if ((Required & Attributes.Phone) == Attributes.Phone)
            {
                ReturnValues.Add(Attributes.Phone, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.phone").Item2);
            }
            if ((Required & Attributes.PostalCode) == Attributes.PostalCode)
            {
                ReturnValues.Add(Attributes.PostalCode, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.postalcode").Item2);
            }
            if ((Required & Attributes.TimeZone) == Attributes.TimeZone)
            {
                ReturnValues.Add(Attributes.TimeZone, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.timezone").Item2);
            }
            if ((Required & Attributes.UserName) == Attributes.UserName)
            {
                ReturnValues.Add(Attributes.UserName, Pairs.Find(x => x.Item1 == "openid." + Extension + ".value.username").Item2);
            }
            return ReturnValues;
        }
Beispiel #13
0
 /// <summary>
 /// Generates a verification URL
 /// </summary>
 /// <param name="Pairs">The individual attribute pairs</param>
 /// <returns>The appropriate verification URL</returns>
 protected string GenerateVerificationUrl(System.Collections.Generic.List<Pair<string, string>> Pairs)
 {
     Pairs.Find(x => x.Left.Equals("openid.mode", StringComparison.CurrentCultureIgnoreCase)).Right = "check_authentication";
     StringBuilder Builder = new StringBuilder();
     Builder.Append(Pairs.Find(x => x.Left.Equals("openid.op_endpoint", StringComparison.CurrentCultureIgnoreCase)).Right);
     string Splitter = "?";
     foreach (Pair<string, string> Pair in Pairs)
     {
         Builder.Append(Splitter).Append(Pair.Left).Append("=").Append(Pair.Right);
         Splitter = "&";
     }
     return Builder.ToString();
 }
Beispiel #14
0
 /// <summary>
 /// Verifies the request
 /// </summary>
 /// <param name="URL">URL returned</param>
 /// <param name="Pairs">Individual attribute pairs</param>
 /// <returns>true if it is valid, false otherwise</returns>
 protected bool Verify(string URL, System.Collections.Generic.List<Pair<string, string>> Pairs)
 {
     Pair<string, string> Mode = Pairs.Find(x => x.Left.Equals("openid.mode", StringComparison.CurrentCultureIgnoreCase));
     if (Mode.Right.Equals("cancel", StringComparison.CurrentCultureIgnoreCase))
         return false;
     Pair<string, string> ReturnTo = Pairs.Find(x => x.Left.Equals("openid.return_to", StringComparison.CurrentCultureIgnoreCase));
     if (ReturnTo == null)
         return false;
     Match PartialUrl = Regex.Match(URL, "^" + ReturnTo.Right, RegexOptions.IgnoreCase);
     if (!PartialUrl.Success)
         return false;
     if (Pairs.Find(x => x.Left.Equals("openid.identity", StringComparison.CurrentCultureIgnoreCase)) == null
         || Pairs.Find(x => x.Left.Equals("openid.claimed_id", StringComparison.CurrentCultureIgnoreCase)) == null)
         return false;
     foreach (IExtension Extension in Extensions)
     {
         if (!Extension.Verify(URL, Pairs))
             return false;
     }
     Pair<string, string> Nonce = Pairs.Find(x => x.Left.Equals("openid.response_nonce", StringComparison.CurrentCultureIgnoreCase));
     if (Nonce == null)
         return false;
     string CurrentNonce = Nonce.Right;
     foreach (string TempNonce in NonceList)
     {
         if (CurrentNonce == TempNonce)
             return false;
     }
     NonceList.Add(CurrentNonce);
     string VerificationURL = GenerateVerificationUrl(Pairs);
     using (WebClient Client = new WebClient())
     {
         string Html = Client.DownloadString(VerificationURL);
         if (!Html.Contains("is_valid:true"))
             return false;
     }
     return true;
 }
Beispiel #15
0
        public static Mock<ITestLinkExtra> _getTestLinkMockWithTestPlans(
           System.Collections.Generic.List<Meyn.TestLink.TestProject> listOfProjects,
           System.Collections.Generic.List<Meyn.TestLink.TestPlan> listOfTestPlans,
           System.Collections.Generic.List<Meyn.TestLink.TestPlatform> listOfTestPlatforms,
           System.Collections.Generic.List<Meyn.TestLink.TestPlanTotal> listOfTestPlanTotals)
        {
            var testLinkMock = _getTestLinkMockWithProjects(listOfProjects);

            testLinkMock.Setup(t => t.GetProjectTestPlans(It.IsAny<int>()))
                .Returns((int prjId) => listOfTestPlans.FindAll(tPlan => tPlan.testproject_id == prjId));

            testLinkMock.Setup(t => t.getTestPlanByName(It.IsAny<string>(), It.IsAny<string>()))
                .Returns((string prjName, string planName) => listOfTestPlans
                         .FindAll(plan => plan.name == planName &&
                                  plan.testproject_id == (listOfProjects.Find(prj => prj.name == prjName)).id)[0]);

            if (null != listOfTestPlatforms) {
                //testLinkMock.Setup(t => t.GetTestPlanPlatforms(It.IsAny<int>())).Returns((int tpId) => listOfTestPlatforms.FindAll(platform => platform.id > 0)); // all
                testLinkMock.Setup(t => t.GetTestPlanPlatforms(It.IsAny<int>())).Returns(() => listOfTestPlatforms); // all
            }

            if (null != listOfTestPlanTotals) {
                testLinkMock.Setup(t => t.GetTotalsForTestPlan(It.IsAny<int>())).Returns(() => listOfTestPlanTotals); // all
            }

            return testLinkMock;
        }
Beispiel #16
0
        public static Mock<ITestLinkExtra> _getTestLinkMockWithTestSuites(
           System.Collections.Generic.List<Meyn.TestLink.TestProject> listOfProjects,
           System.Collections.Generic.List<Meyn.TestLink.TestPlan> listOfTestPlans,
           System.Collections.Generic.List<Meyn.TestLink.TestPlatform> listOfTestPlatforms,
           System.Collections.Generic.List<Meyn.TestLink.TestPlanTotal> listOfTestPlanTotals,
           System.Collections.Generic.List<Meyn.TestLink.Build> listOfBuilds,
           System.Collections.Generic.List<Meyn.TestLink.TestSuite> listOfTestSuites)
        {
            var testLinkMock = _getTestLinkMockWithBuilds(listOfProjects, listOfTestPlans, listOfTestPlatforms, listOfTestPlanTotals, listOfBuilds);

            testLinkMock.Setup(t => t.GetTestSuitesForTestPlan(It.IsAny<int>())).Returns(() => listOfTestSuites);

            //testLinkMock.Setup(t => t.CreateTestSuite

            testLinkMock.Setup(t => t.GetFirstLevelTestSuitesForTestProject(It.IsAny<int>())).Returns(() => listOfTestSuites);

            //testLinkMock.Setup(t => t.GetTestCasesForTestSuite

            testLinkMock.Setup(t => t.GetTestSuiteById(It.IsAny<int>())).Returns((int id) => listOfTestSuites.Find(ts => ts.id == id));

            testLinkMock.Setup(t => t.GetTestSuitesForTestSuite(It.IsAny<int>())).Returns((int id) => listOfTestSuites.FindAll(ts => ts.parentId == id));

            //testLinkMock.Setup(t => t.UploadTestSuiteAttachment

            return testLinkMock;
        }
		public void FindThrowsArgumentNullExceptionIfPropertyAccessorIsNull()
		{
			var dummySource = new[] {1, 2, 3};
			Expression<Func<int, int>> propertyAccessor = null;
			// ReSharper disable once ExpressionIsAlwaysNull
			var ex = TestUtils.ExpectException<ArgumentNullException>(() => dummySource.Find(propertyAccessor, 2));
			Assert.AreEqual("propertyAccessor", ex.ParamName, "ParamName");
		}