internal static string Build(List<TestAttribute> Categories)
        {
            string source = "";

            var list = new List<string>();

            Categories
                .ToList()
                .ForEach(c => list.Add(c.GetName()));

            list.Sort();

            var catParams = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            list.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), catParams, catValues);
            });

            return source;
        }
        public static List<TagProcessResult> ProcessTagSet(List<TagSimple> tagSet)
        {
            var resultList = new List<TagProcessResult>();

             // Spellcheck
             tagSet.ForEach(t => resultList.Add(
            new TagProcessResult
            {
               TagId = t.TagId,
               TagValue = t.TagValue,
               WordProcessResultList = t.TagValue.Split(' ').ToList().Select(w => ProcessWord(w, t.TagId)).ToList()
            }));

             var correctlySpelledTagList = resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList();

             resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetTest(correctlySpelledTagList, tpr));

             //// Check all tags that are 100% spelled correctly for a duplicate in provided set.
             //resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetForDuplicates(correctlySpelledTagList, tpr));

             //// Check all tags that are unique in the provided set of tags and are 100% spelled correctly for a duplicate in the media tag repository.
             //resultList.Where(t => !t.DuplicateTagId.HasValue && t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(CheckRepositoryForDuplicates);

             //resultList.Where(t => !t.MediaTagId.HasValue).ToList().ForEach(t => CheckTagSetForSynonyms(correctlySpelledTagList, t));

             return resultList;
        }
Esempio n. 3
0
 private static void InsertPedidos(PedidoDAL pedidoDAL)
 {
     pedidos = new List<Pedido>
         {
             new Pedido { DataPedido = DateTime.Now,Vendedor = "Vendedor A",Situacao = false,Observacao = "Obsevação A",Produtos = produtos }
         };
     pedidos.ForEach(pedidoDAL.Insert);
 }
Esempio n. 4
0
 private static void InsertProdutos(ProdutoDAL produtoDAL)
 {
     produtos = new List<Produto>
         {
             new Produto { Nome="Produto A",Peso = 100,Quantidade = 1,preco = 50.25M},
             new Produto { Nome="Produto B",Peso = 200,Quantidade = 1,preco = 65.25M},
             new Produto { Nome="Produto C",Peso = 300,Quantidade = 4,preco = 125.25M }
         };
     produtos.ForEach(produtoDAL.Insert); ;
 }
        public static string buildOptions(List<string> Categories)
        {
            string source = "";

            Categories.Sort();

            var catFlags = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            Categories.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryHtml.GetOptionSource(), catFlags, catValues);
            });

            return source;
        }
        public void RestoreAzureWebsiteDeploymentTest()
        {
            // Setup
            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();

            channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } });
            channel.GetSitesThunk = ar =>
            {
                if (ar.Values["webspaceName"].Equals("webspace1"))
                {
                    return new Sites(new List<Site> { new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties
                        {
                            Properties = new List<NameValuePair>
                            {
                                new NameValuePair { Name = "repositoryuri", Value = "http" },
                                new NameValuePair { Name = "PublishingUsername", Value = "user1" },
                                new NameValuePair { Name = "PublishingPassword", Value = "password1" }
                            }
                        }}
                    });
                }

                return new Sites(new List<Site> { new Site { Name = "website2", WebSpace = "webspace2" } });
            };

            SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement();

            var deployments = new List<DeployResult> { new DeployResult { Id = "id1", Current = false }, new DeployResult { Id = "id2", Current = true } };
            deploymentChannel.GetDeploymentsThunk = ar => deployments;
            deploymentChannel.DeployThunk = ar =>
            {
                // Keep track of currently deployed id
                DeployResult newDeployment = deployments.FirstOrDefault(d => d.Id.Equals(ar.Values["commitId"]));
                if (newDeployment != null)
                {
                    // Make all inactive
                    deployments.ForEach(d => d.Complete = false);

                    // Set new to active
                    newDeployment.Complete = true;
                }
            };

            // Test
            RestoreAzureWebsiteDeploymentCommand restoreAzureWebsiteDeploymentCommand =
                new RestoreAzureWebsiteDeploymentCommand(channel, deploymentChannel)
            {
                Name = "website1",
                CommitId = "id2",
                ShareChannel = true,
                CommandRuntime = new MockCommandRuntime(),
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }
            };

            restoreAzureWebsiteDeploymentCommand.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime) restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count);
            var responseDeployments = (IEnumerable<DeployResult>)((MockCommandRuntime) restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.IsNotNull(responseDeployments);
            Assert.AreEqual(2, responseDeployments.Count());
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id2") && d.Complete));
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id1") && !d.Complete));

            // Change active deployment to id1
            restoreAzureWebsiteDeploymentCommand = new RestoreAzureWebsiteDeploymentCommand(channel, deploymentChannel)
            {
                Name = "website1",
                CommitId = "id1",
                ShareChannel = true,
                CommandRuntime = new MockCommandRuntime(),
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }
            };

            restoreAzureWebsiteDeploymentCommand.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime)restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count);
            responseDeployments = (IEnumerable<DeployResult>)((MockCommandRuntime)restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.IsNotNull(responseDeployments);
            Assert.AreEqual(2, responseDeployments.Count());
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id1") && d.Complete));
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id2") && !d.Complete));
        }
Esempio n. 7
0
        public void MatchSaveTest()
        {
            const int countryId = 66;
            var country = TestEntities.CreateCountry(countryId, "countryEnglishName", "CountryName");
            var series = TestEntities.CreateSeries(1000, country, "A Lyga");
            var sessionFactory = SessionFactory.CreateSessionFactory(true);
            using (var session = sessionFactory.OpenSession())
            {
                session.SaveOrUpdate(country);
                session.SaveOrUpdate(series);
                session.Flush();
            }

            var match1 = TestEntities.CreateMatchFullData(1000, country, 1050, 1051,
                                                          new List<int> {10000, 10001, 10002}, 3000, 1);

            var match2 = TestEntities.CreateMatchFullData(1001, country, 1052, 1053,
                                              new List<int> { 10003, 10004, 10005 }, 3001, 1);

            series.AddMatch(match1);
            series.AddMatch(match2);

            var matchList = new List<Match> { match1, match2 };

            var prodSession = SessionManager.CurrentSession;
            var matchRepository = new MatchRepository(prodSession);

            using (var transaction = prodSession.BeginTransaction())
            {
                matchList.ForEach(matchRepository.SaveUpdate);
                transaction.Commit();
            }
        }
        /// <summary>
        /// Set up runtime deployment info for each role in the service - after this method is called, 
        /// each role will have its startup configured with the URI of a runtime package to install at 
        /// role start
        /// </summary>
        /// <param name="service">The service to prepare</param>
        /// <param name="settings">The runtime settings to use to determine location</param>
        /// <param name="manifest"> </param>
        /// <returns>True if requested runtimes were successfully resolved, otherwise false</returns>
        internal bool PrepareRuntimeDeploymentInfo(AzureService service, ServiceSettings settings, string manifest = null)
        {
            CloudRuntimeCollection availableRuntimePackages;
            LocationName deploymentLocation = GetSettingsLocation(settings);
            if (!CloudRuntimeCollection.CreateCloudRuntimeCollection(deploymentLocation,
                out availableRuntimePackages, manifestFile: manifest))
            {
                throw new ArgumentException(string.Format(Resources.ErrorRetrievingRuntimesForLocation,
                    deploymentLocation));
            }

            ServiceDefinitionSchema.ServiceDefinition definition = service.Components.Definition;
            StringBuilder warningText = new StringBuilder();
            bool shouldWarn = false;
            List<CloudRuntimeApplicator> applicators = new List<CloudRuntimeApplicator>();
            if (definition.WebRole != null)
            {
                foreach (ServiceDefinitionSchema.WebRole role in definition.WebRole.Where(role => role.Startup != null && CloudRuntime.GetRuntimeStartupTask(role.Startup) != null))
                {
                    CloudRuntime.ClearRuntime(role);
                    string rolePath = Path.Combine(service.Paths.RootPath, role.name);
                    foreach (CloudRuntime runtime in CloudRuntime.CreateRuntime(role, rolePath))
                    {
                        CloudRuntimePackage package;
                        if (!availableRuntimePackages.TryFindMatch(runtime, out package))
                        {
                            string warning;
                            if (!runtime.ValidateMatch(package, out warning))
                            {
                                shouldWarn = true;
                                warningText.AppendFormat("{0}\r\n", warning);
                            }
                        }

                        applicators.Add(CloudRuntimeApplicator.CreateCloudRuntimeApplicator(runtime,
                            package, role));
                    }
                }
            }

            if (definition.WorkerRole != null)
            {
                foreach (ServiceDefinitionSchema.WorkerRole role in definition.WorkerRole.Where(role => role.Startup != null && CloudRuntime.GetRuntimeStartupTask(role.Startup) != null))
                {
                    string rolePath = Path.Combine(service.Paths.RootPath, role.name);
                    CloudRuntime.ClearRuntime(role);
                    foreach (CloudRuntime runtime in CloudRuntime.CreateRuntime(role, rolePath))
                    {
                        CloudRuntimePackage package;
                        if (!availableRuntimePackages.TryFindMatch(runtime, out package))
                        {
                            string warning;
                            if (!runtime.ValidateMatch(package, out warning))
                            {
                                shouldWarn = true;
                                warningText.AppendFormat("{0}\r\n", warning);
                            }
                        }
                        applicators.Add(CloudRuntimeApplicator.CreateCloudRuntimeApplicator(runtime,
                            package, role));
                    }
                }
            }

            if (!shouldWarn || ShouldProcess(string.Format(Resources.RuntimeMismatchWarning,
                _azureService.ServiceName)))
            {
                if (!shouldWarn || Force || ShouldContinue(warningText.ToString(),
                    string.Format(Resources.RuntimeMismatchWarning, _azureService.ServiceName)))
                {
                    applicators.ForEach<CloudRuntimeApplicator>(a => a.Apply());
                    service.Components.Save(service.Paths);
                    return true;
                }
            }

            return false;
        }
Esempio n. 9
0
 private void SortCoordinates(List<District> districts)
 {
     districts.ForEach(d => d.Coordinates = d.Coordinates.OrderBy(c => c.Index).ToList());
 }