예제 #1
0
 public static Post BuildChangedCategoryByModeratorPost(Moderator moderator, string reason)
 {
     return new Post
     {
         Author = moderator.User,
         Type = PostType.Answer,
         Content = string.Format(Resources.Thread.ChangedCategoryByModeratorPost, moderator.PublicName, reason)
     };
 }
예제 #2
0
        private void GenerateBDDTestingData()
        {
            //generating users
            var userSalt = CryptoHelper.CreateSalt();

            var user = new User
            {
                Email = "*****@*****.**",
                IsActivated = true,
                Password = "******",
                PasswordSalt = userSalt,
                BankAccountNumber = "654510157739999994584019961664"
            };

            Repository.User.Add(user);
            Repository.User.AddEmailConfigurationDefaultValue(user);

            var moderator = new Moderator
            {
                PublicName = "Szalony Moderator",

                User = new User
                {
                    Email = "*****@*****.**",
                    IsActivated = true,
                    Password = "******",
                    PasswordSalt = userSalt,
                    BankAccountNumber = "116910157739999994584019961664"
                }
            };

            Repository.User.Add(moderator.User);
            Repository.Moderator.Add(moderator);
            Repository.User.AddEmailConfigurationDefaultValue(moderator.User);

            var expert1 = new Expert
            {
                FirstName = "test-name",
                LastName = "test-surname",
                PublicName = "test-expert",
                PhoneNumber = "671707525",
                VerificationStatus = ExpertVerificationStatus.Verified,
                User = new User
                {
                    Email = "*****@*****.**",
                    IsActivated = true,
                    Password = "******",
                    PasswordSalt = userSalt,
                    BankAccountNumber = "204510157739991764584019961664"
                }
            };

            foreach (var category in Repository.Category.All())
            {
                expert1.Categories.Add(category);
                expert1.CategoryAttributes.Add(new ExpertCategoryAttributeValues
                                                    {
                                                        Category = category,
                                                        ExpertReason = category.Name + " dfuq am i doing here"}
                                                    );
            }

            expert1.Microprofiles.Add(new ExpertMicroprofile
            {
                Description = "test-desc",
                Position = "test-position"
            });

            Repository.User.Add(expert1.User);
            Repository.Expert.Add(expert1);
            Repository.User.AddEmailConfigurationDefaultValue(expert1.User);
            Repository.Expert.AssignProvisionToExpert(expert1, ProvisionExpert.Novice);

            Repository.Partner.Create(expert1.User);

            var expert2 = new Expert
            {
                FirstName = "test-name2",
                LastName = "test-surname2",
                PublicName = "test-expert2",
                PhoneNumber = "271707325",
                VerificationStatus = ExpertVerificationStatus.Verified,
                User = new User
                {
                    Email = "*****@*****.**",
                    IsActivated = true,
                    Password = "******",
                    PasswordSalt = userSalt,
                    BankAccountNumber = "404510157739991344584019961664"
                }
            };

            foreach (var category in Repository.Category.All())
            {
                expert2.Categories.Add(category);
                expert2.CategoryAttributes.Add(new ExpertCategoryAttributeValues
                {
                    Category = category,
                    ExpertReason = category.Name + " dfuq am i doing here 2"
                }
                                                    );
            }

            expert2.Microprofiles.Add(new ExpertMicroprofile
            {
                Description = "test-desc2",
                Position = "test-position2"
            });

            Repository.User.Add(expert2.User);
            Repository.Expert.Add(expert2);
            Repository.User.AddEmailConfigurationDefaultValue(expert2.User);
            Repository.Expert.AssignProvisionToExpert(expert2, ProvisionExpert.Novice);

            Repository.Partner.Create(expert2.User);

            //generating threads
            
            //zadane, opłacone pytanie ([email protected]) bez eksperta
            var thread1 = new Thread
                             {
                                 Priority = ThreadPriority.Medium,
                                 Verbosity = ThreadVerbosity.Low,
                                 State = ThreadState.Unoccupied,
                                 SanitizationStatus = ThreadSanitizationStatus.NotSanitized,
                                 Value = 5.00m,
                                 IsPaid = true,
                                 Author = user,
                                 Posts = new List<Post>{new Post
                                                            {
                                                                Content = "Pytanie testowe bez eksperta",
                                                                CreationDate = DateTime.Now.AddDays(-2),
                                                                LastModificationDate = DateTime.Now.AddDays(-2),
                                                                Type = PostType.Question,
                                                                Author = user
                                                            }
                                 },
                                 Category = Repository.Category.Find(c => c.Name == "Nauka")
                             };

            thread1.PriceProposals.Add(new PriceProposal
                                           {
                                               Comment = "Proponuje wyższą cenę",
                                               CreationDate = DateTime.Now.AddDays(-1),
                                               LastModificationDate = DateTime.Now.AddDays(-1),
                                               Expert = expert2,
                                               SurchargeValue = 10,
                                               VerificationStatus = PriceProposalVerificationStatus.Verified
                                           });

            Repository.Thread.Add(thread1);

            thread1.CreationDate = DateTime.Now.AddDays(-2);
            Repository.Thread.Update(thread1);

            //zadane, opłacone pytanie z autorem ([email protected]) z ekspertem ([email protected])
            var thread2 = new Thread
                              {
                                  Priority = ThreadPriority.Medium,
                                  Verbosity = ThreadVerbosity.Low,
                                  State = ThreadState.Occupied,
                                  SanitizationStatus = ThreadSanitizationStatus.NotSanitized,
                                  Value = 5.00m,
                                  IsPaid = true,
                                  Author = user,
                                  Expert = expert1,
                                  Posts = new List<Post>
                                              {
                                                  new Post
                                                      {
                                                          Content = "Pytanie testowe z ekspertem",
                                                          Type = PostType.Question,
                                                          Author = user
                                                      },
                                                  new Post
                                                      {
                                                          Content = "Odpowiedź testowa",
                                                          Type = PostType.Answer,
                                                          Author = expert1.User
                                                      }
                                              },
                                  Category = Repository.Category.Find(c => c.Name == "Nauka")
                              };

            Repository.Thread.Add(thread2);

            // zadane, nieopłacone pytanie
            var thread3 = new Thread
                              {
                                  Priority = ThreadPriority.Medium,
                                  Verbosity = ThreadVerbosity.High,
                                  State = ThreadState.Unoccupied,
                                  SanitizationStatus = ThreadSanitizationStatus.NotSanitized,
                                  Value = 20.00m,
                                  IsPaid = false,
                                  Author = user,
                                  Posts = new List<Post>
                                              {
                                                  new Post
                                                      {
                                                          Content = "Nieopłacone pytanie testowe",
                                                          Type = PostType.Question,
                                                          Author = user
                                                      }
                                              },
                                  Category = Repository.Category.Find(c => c.Name == "Nauka")
                              };

            Repository.Thread.Add(thread3);

            var thread4 = new Thread
                              {
                                  Priority = ThreadPriority.Low,
                                  Verbosity = ThreadVerbosity.Medium,
                                  State = ThreadState.Closed,
                                  SanitizationStatus = ThreadSanitizationStatus.NotSanitized,
                                  Value = 10.00m,
                                  IsPaid = true,
                                  Author = user,
                                  Posts = new List<Post>
                                              {
                                                  new Post
                                                      {
                                                          Content = "Zamknięte pytanie testowe",
                                                          Type = PostType.Question,
                                                          Author = user
                                                      },
                                                  new Post
                                                      {
                                                          Content = "Odpowiedź testowa",
                                                          Type = PostType.Answer,
                                                          Author = expert1.User
                                                      }
                                              },
                                  Category = Repository.Category.Find(c => c.Name == "Nauka")
                              };

            Repository.Thread.Add(thread4);

            //zamkniete i oczyszczone pytanie
            var thread5 = new Thread
                              {
                                  Priority = ThreadPriority.Low,
                                  Verbosity = ThreadVerbosity.Medium,
                                  State = ThreadState.Closed,
                                  SanitizationStatus = ThreadSanitizationStatus.Sanitized,
                                  Value = 10.00m,
                                  IsPaid = true,
                                  Author = user,
                                  Expert = expert1,
                                  Posts = new List<Post>
                                              {
                                                  new Post
                                                      {
                                                          Content = "Zamknięte pytanie testowe sanitized",
                                                          Type = PostType.Question,
                                                          Author = user
                                                      },
                                                  new Post
                                                      {
                                                          Content = "Odpowiedź testowa sanitized",
                                                          Type = PostType.Answer,
                                                          Author = expert1.User
                                                      }
                                              },
                                  Category = Repository.Category.Find(c => c.Name == "Nauka")
                              };
            Repository.Thread.Add(thread5);

            /* generating SEO keywords */
            var seoKeyword1 = new SEOKeyword
                                 {
                                     Category = Repository.Category.Find(c => c.Name == "Nauka"),
                                     Phrase = "ekspert",
                                     Type = SEOKeywordType.Expert,
                                     Status = SEOKeywordStatus.Processed,
                                     Source = SEOKeywordSource.Automatic
                                 };
            Repository.SEOKeyword.Add(seoKeyword1);

            var seoKeyword2 = new SEOKeyword
            {
                Category = Repository.Category.Find(c => c.Name == "Nauka"),
                Phrase = "fraza",
                Type = SEOKeywordType.Phrase,
                Status = SEOKeywordStatus.Processed,
                Source = SEOKeywordSource.Automatic
            };
            Repository.SEOKeyword.Add(seoKeyword2);

            var seoKeyword3 = new SEOKeyword
            {
                Category = Repository.Category.Find(c => c.Name == "Nauka"),
                Phrase = "pytanie",
                Type = SEOKeywordType.Question,
                Status = SEOKeywordStatus.Processed,
                Source = SEOKeywordSource.Automatic
            };
            Repository.SEOKeyword.Add(seoKeyword3);
        }