Example #1
0
 public FakerContainer()
 {
     Address       = new AddressFaker(this);
     App           = new AppFaker(this);
     Beer          = new BeerFaker(this);
     Book          = new BookFaker(this);
     Boolean       = new BooleanFaker();
     Business      = new BusinessFaker(this);
     Color         = new ColorFaker(this);
     Company       = new CompanyFaker(this);
     Date          = new DateFaker();
     Fake          = new FakeFaker(this);
     Friends       = new FriendsFaker(this);
     GameOfThrones = new GameOfThronesFaker(this);
     Lorem         = new LoremFaker(this);
     Name          = new NameFaker(this);
     Number        = new NumberFaker();
     Pokemon       = new PokemonFaker(this);
     Random        = new RandomFaker();
     RockBand      = new RockBandFaker(this);
     Superhero     = new SuperheroFaker(this);
     Team          = new TeamFaker(this);
     Time          = new TimeFaker();
     TwinPeaks     = new TwinPeaksFaker(this);
     Zelda         = new ZeldaFaker(this);
 }
Example #2
0
        public void CreatePostTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var postId = postBll.CreatePost(new PostViewModel()
            {
                UserId      = userId,
                PostDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                CreatedTime =
                    DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotEmpty(postId);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(postId);
            }
        }
Example #3
0
        public void Pupolate()
        {
            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userIds    = userList.Select(r => r.Id).ToArray();

            for (var i = 0; i < 1000; i++)
            {
                var post = new Post()
                {
                    UserId       = ArrayFaker.SelectFrom(userIds),
                    PostDetails  = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                    CreatedTime  = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                    LikedUserIds = ArrayFaker.SelectFrom(NumberFaker.Number(0, 5), userIds).ToList(),
                    Comments     = new List <Comment>()
                    {
                        new Comment()
                        {
                            CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                            CreatedTime    =
                                DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                            UserId = ArrayFaker.SelectFrom(userIds),
                        },
                        new Comment()
                        {
                            CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                            CreatedTime    =
                                DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                            UserId = ArrayFaker.SelectFrom(userIds),
                        }
                    }
                };
                postRepo.Add(post);
            }
        }
Example #4
0
        public void GetUserByIdTest()
        {
            var userBll = new UserBLL();

            var users = userBll.GetAllUser(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3), ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var user = users.First();

            var foundUser = userBll.GetUserById(user.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.Null(foundUser);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(foundUser);
            }

            var testSameId = foundUser.Id.Equals(user.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testSameId);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testSameId);
            }
        }
Example #5
0
 public void NumberFakerTest()
 {
     DisplayAndExecute(new Expression <Func <int> >[] {
         () => NumberFaker.Number(),
         () => NumberFaker.Number(10),
         () => NumberFaker.Number(10, 100),
     });
 }
Example #6
0
 public static string Email()
 {
     if (NumberFaker.Number(5) != 2)
     {
         return(string.Concat(NameFaker.FirstName().ToLower(), "@", InternetFaker.Domain()));
     }
     return(string.Concat(NameFaker.FirstName().ToLower(), StringFaker.Numeric(2), "@", InternetFaker.Domain()));
 }
Example #7
0
        public static void DemoEnterEMail(string email = "")
        {
            if (email == "")
            {
                email = Faker.NameFaker.FirstName() + NumberFaker.Number(99) + "@yopmail.com";
            }

            Browser.EnterText(BySelection.Name, EmailID, email);
        }
Example #8
0
        public static void DowningRegEnterEmail(string emailAddress = "")
        {
            if (emailAddress == "")
            {
                emailAddress = Faker.NameFaker.FirstName() + NumberFaker.Number(999) + "@yopmail.com";
            }
            Browser.EnterText(BySelection.Id, EmailID, emailAddress);
            ExcelDataAccess excelDataAccess = new ExcelDataAccess();

            excelDataAccess.WriteTestData("Email address:" + "" + emailAddress);
        }
Example #9
0
        private Article CreateRandomArticle()
        {
            var result = new Article();

            result.Body        = TextFaker.Sentences(NumberFaker.Number());
            result.Description = TextFaker.Sentence();
            result.Id          = NumberFaker.Number().ToString();
            result.Title       = TextFaker.Sentence();

            return(result);
        }
Example #10
0
        public void UpatePostTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var userId = userList.First().Id;

            var userIds = userList.Select(r => r.Id).ToList();

            postBll.CreatePost(new PostViewModel()
            {
                UserId      = userId,
                PostDetails = TextFaker.Sentences(5),
                CreatedTime = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });

            var posts = postBll.GetAllPost(userId);

            var post = posts.First();

            var test = postBll.UpatePost(new PostViewModel()
            {
                Id           = post.Id,
                UserId       = post.UserId,
                PostDetails  = TextFaker.Sentences(NumberFaker.Number(5, 30)),
                LikedUserIds = userIds,
                CreatedTime  = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });


            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var updatedPost = postBll.GetPostByID(post.Id);

            var testNoOfUserLike = updatedPost.LikedUserIds.Count() == userId.Count();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testNoOfUserLike);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testNoOfUserLike);
            }
        }
Example #11
0
 public FakerContainer()
 {
     App     = new AppFaker(this);
     Book    = new BookFaker(this);
     Boolean = new BooleanFaker();
     Date    = new DateFaker();
     Fake    = new FakeFaker(this);
     Name    = new NameFaker(this);
     Number  = new NumberFaker();
     Random  = new RandomFaker();
     Time    = new TimeFaker();
 }
Example #12
0
 public void Pupolate()
 {
     for (var i = 0; i < 100; i++)
     {
         var post           = postRepo.Get().Skip(NumberFaker.Number(1, 100)).First();
         var restrictedPost = new RestrictedPost()
         {
             PostId = post.Id.ToString(),
             UserId = post.UserId
         };
         restrictedPostRepo.Add(restrictedPost);
     }
 }
Example #13
0
        public void AddCommentsTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var posts = postBll.GetAllPost(userId);

            var test = posts.Any();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var post = posts.First();

            post = postBll.GetPostByID(post.Id);

            var userIds = userList.Select(r => r.Id).ToArray();

            var comment = new CommentViewModel()
            {
                PostId         = post.Id,
                CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                CreatedTime    =
                    DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                UserId = ArrayFaker.SelectFrom(userIds)
            };

            postBll.AddComments(comment);

            var postWithComment = postBll.GetPostByID(post.Id);

            var testCommentInsert = post.Comments.Count() == postWithComment.Comments.Count() - 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testCommentInsert);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testCommentInsert);
            }
        }
Example #14
0
 public FakerContainer()
 {
     Address        = new AddressFaker(this);
     Ancient        = new AncientFaker(this);
     App            = new AppFaker(this);
     Avatar         = new AvatarFaker(this);
     Beer           = new BeerFaker(this);
     Book           = new BookFaker(this);
     Boolean        = new BooleanFaker();
     Business       = new BusinessFaker(this);
     Cat            = new CatFaker(this);
     ChuckNorris    = new ChuckNorrisFaker(this);
     Coffee         = new CoffeeFaker(this);
     Color          = new ColorFaker(this);
     Company        = new CompanyFaker(this);
     Date           = new DateFaker();
     DragonBall     = new DragonBallFaker(this);
     Educator       = new EducatorFaker(this);
     Fake           = new FakeFaker(this);
     File           = new FileFaker(this);
     Fillmurray     = new FillmurrayFaker();
     Food           = new FoodFaker(this);
     Friends        = new FriendsFaker(this);
     GameOfThrones  = new GameOfThronesFaker(this);
     Hacker         = new HackerFaker(this);
     HarryPotter    = new HarryPotterFaker(this);
     Internet       = new InternetFaker(this);
     LordOfTheRings = new LordOfTheRingsFaker(this);
     Lorem          = new LoremFaker(this);
     Music          = new MusicFaker(this);
     Name           = new NameFaker(this);
     Number         = new NumberFaker();
     PhoneNumber    = new PhoneNumberFaker(this);
     Placeholdit    = new PlaceholditFaker(this);
     Pokemon        = new PokemonFaker(this);
     Random         = new RandomFaker();
     RickAndMorty   = new RickAndMortyFaker(this);
     RockBand       = new RockBandFaker(this);
     SlackEmoji     = new SlackEmojiFaker(this);
     Space          = new SpaceFaker(this);
     StarWars       = new StarWarsFaker(this);
     Superhero      = new SuperheroFaker(this);
     Team           = new TeamFaker(this);
     Time           = new TimeFaker();
     TwinPeaks      = new TwinPeaksFaker(this);
     University     = new UniversityFaker(this);
     Vehicle        = new VehicleFaker(this);
     Zelda          = new ZeldaFaker(this);
 }
Example #15
0
        public static Product GetProduct()
        {
            var product = new Product()
            {
                Id           = Guid.NewGuid(),
                Category     = StringFaker.Alpha(10),
                Condition    = TextFaker.Sentences(4),
                Description  = TextFaker.Sentences(7),
                Name         = StringFaker.Alpha(40),
                Location     = LocationFaker.City(),
                Manufacturer = StringFaker.Alpha(25),
                Price        = NumberFaker.Number(1, 500)
            };

            return(product);
        }
Example #16
0
 private IEnumerable <InstanceInfo> CreateSomeRandomInstances()
 {
     for (int i = 0; i < NumberFaker.Number(10, 20); i++)
     {
         yield return(new InstanceInfo()
         {
             InstanceId = "i-" + StringFaker.AlphaNumeric(8).ToLower(),
             IpAddress = IpAddressFaker.IpAddress(),
             Status = NumberFaker.Number(1, 10) < 9 ? InstanceStatuses.Running : InstanceStatuses.Pending,
             WorkerInfo = new WorkerInfo()
             {
                 WorkerOnline = false
             }
         });
     }
 }
Example #17
0
        public void GetAllUserTest()
        {
            var userBll = new UserBLL();

            var users = userBll.GetAllUser(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3), ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var test = users.Any();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Example #18
0
 public FakerContainer()
 {
     Address  = new AddressFaker(this);
     App      = new AppFaker(this);
     Book     = new BookFaker(this);
     Boolean  = new BooleanFaker();
     Business = new BusinessFaker(this);
     Date     = new DateFaker();
     Fake     = new FakeFaker(this);
     Friends  = new FriendsFaker(this);
     Lorem    = new LoremFaker(this);
     Name     = new NameFaker(this);
     Number   = new NumberFaker();
     Pokemon  = new PokemonFaker(this);
     Random   = new RandomFaker();
     Time     = new TimeFaker();
     Zelda    = new ZeldaFaker(this);
 }
Example #19
0
        public IEnumerable <Article> GetArticles()
        {
            var result = new Article();

            result.Body        = TextFaker.Sentences(NumberFaker.Number());
            result.Description = TextFaker.Sentence();
            result.Id          = NumberFaker.Number().ToString();
            result.Title       = TextFaker.Sentence();


            List <Article> list = new List <Article>();

            for (var i = 0; i < 100; i++)
            {
                list.Add(CreateRandomArticle());
            }


            return(list);
        }
        public void PostPostTest()
        {
            var controller = getController();

            var postVm = new PostViewModel()
            {
                PostDetails = TextFaker.Sentences(NumberFaker.Number(5, 25))
            };

            var result = controller.PostPost(postVm);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(result);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(result);
            }
        }
        public void PutPostTest()
        {
            var controller = getController();

            var post = controller.GetAllPosts().First();

            var postVm = new PostViewModel()
            {
                Id          = post.Id,
                PostDetails = TextFaker.Sentences(NumberFaker.Number(5, 25))
            };

            var result = controller.PutPost(postVm);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(result);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(result);
            }
        }
Example #22
0
        public void TestSetup()
        {
            converter = new ProductConverter();

            fakeProduct = new Product
            {
                Id                           = NumberFaker.Number(1, int.MaxValue),
                Name                         = StringFaker.Alpha(20),
                ReleaseDate                  = DateTime.Now,
                Notes                        = TextFaker.Sentences(5),
                LicenseEncryptionType        = EncryptionType.RSA_4096,
                PrivateKey                   = StringFaker.AlphaNumeric(50),
                PublicKey                    = StringFaker.AlphaNumeric(50),
                DefaultLockProperties        = LockPropertyType.CPU | LockPropertyType.BIOS,
                FailOnNullHardwareIdentifier = BooleanFaker.Boolean(),
                PermittedActivationTypes     = ActivationMethodType.Manual | ActivationMethodType.Email,
                PermittedExpirationTypes     = LicenseType.Service,
                VersionLeeway                = VersionLeewayType.Strict,
            };

            fakeViewmodel = new ProductViewModel
            {
                Id          = NumberFaker.Number(1, int.MaxValue),
                Name        = StringFaker.Alpha(20),
                ReleaseDate = DateTime.Now,
                Notes       = TextFaker.Sentences(5),
                SelectedDefaultLockProperties = new List <string> {
                    ((int)LockPropertyType.CPU).ToString(), ((int)LockPropertyType.BIOS).ToString()
                },
                FailOnNullHardwareIdentifier = BooleanFaker.Boolean(),
                PermittedActivationTypes     = new List <string> {
                    ((int)ActivationMethodType.Manual).ToString(), ((int)ActivationMethodType.Email).ToString()
                },
                // randomly selects a versionleewaytype
                VersionLeeway = ((int)VersionLeewayType.Strict).ToString()
            };
        }
Example #23
0
 public static int StreetNumber()
 {
     return(NumberFaker.Number(1, 50));
 }
Example #24
0
        public void Friend_Suggestion_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 2),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get Seven user to make friend
            var userIds = userList.Select(r => r.Id).Take(7).ToList();

            var userId = userIds.First();

            var friendId = userIds.Skip(1).First();

            //Test whether thay are friend or not
            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(2).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(3).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }


            friendId = userIds.Skip(4).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(1).First();

            friendId = userIds.Skip(2).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(5).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(3).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(4).First();

            friendId = userIds.Skip(6).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.First();

            // Get Suggested Friend of 'A' should found 'C' and 'G'

            var suggestedFriends = repo.GetFriendSuggestion(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(suggestedFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(suggestedFriends);
            }

            var test = suggestedFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var suggestedFriendIds = suggestedFriends.Select(r => r.UserId.Equals(userId) ? r.FriendId : r.UserId);

            test = suggestedFriendIds.Contains(userIds.Skip(5).First());

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            test = suggestedFriendIds.Contains(userIds.Skip(6).First());

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Example #25
0
        public void Find_Mutual_Friend_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 2),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get three user to make friend
            var userId = userList.Select(r => r.Id).First();

            var friendId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            var mutualFriend = userList.Where(r => r.Id != userId && r.Id != friendId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            alreadyFriend = repo.IsExistsFriend(mutualFriend, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(mutualFriend, friendId);
                repo.AcceptFriendRequest(mutualFriend, friendId);
                alreadyFriend = repo.IsExistsFriend(mutualFriend, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            //Test whether thay are friend or not

            alreadyFriend = repo.IsExistsFriend(mutualFriend, userId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(mutualFriend, userId);
                repo.AcceptFriendRequest(mutualFriend, userId);
                alreadyFriend = repo.IsExistsFriend(mutualFriend, userId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            // Get Mutual friend -> Mr X and Mr Y found Mr. Z

            var mutualFriends = repo.GetMutualFriend(userId, mutualFriend);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            var test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Y and Mr X found Mr. Z

            mutualFriends = repo.GetMutualFriend(mutualFriend, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Y and Mr Z found Mr. X

            mutualFriends = repo.GetMutualFriend(mutualFriend, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Z and Mr Y found Mr. X

            mutualFriends = repo.GetMutualFriend(friendId, mutualFriend);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Z and Mr X found Mr. Y

            mutualFriends = repo.GetMutualFriend(friendId, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr X and Mr Z found Mr. Y

            mutualFriends = repo.GetMutualFriend(friendId, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Example #26
0
        public void Send_And_Reject_Friend_Request_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get two user to make friend
            var userId = userList.Select(r => r.Id).First();

            var friendId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (alreadyFriend)
            {
                // They are friend so try to find who are not friend
                //userId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

                //friendId = userList.Where(r => r.Id != userId && r.Id != friendId).Select(r => r.Id).First();

                // Remove friend
                var removeThemFriend = repo.RemoveFriend(userId, friendId);

                if (TestingConfig.XUnit)
                {
                    Xunit.Assert.True(removeThemFriend);
                }
                else
                {
                    Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(removeThemFriend);
                }

                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.False(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(alreadyFriend);
            }

            // Send friend request
            var test = repo.SendFriendRequest(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Now one send friend request to other
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            /*
             * // Get request object to reject
             * var friend = repo.GetFriendRequest(userId, friendId);
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.NotNull(friend);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(friend);
             *
             * var testFriendIds = friend.UserId == userId && friend.FriendId == friendId;
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.True(test);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
             *
             * // Check friend request has been pending
             * var testPendingFriendRequest = friend.IsAccepted;
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.False(testPendingFriendRequest);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(testPendingFriendRequest);
             */

            // Check all request of a user
            var friendRequests = repo.GetAllFriendRequestsByUser(friendId);

            friendRequests = repo.GetAllFriendRequestsByUser(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(friendRequests);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(friendRequests);
            }

            var testFriendRequests = friendRequests.Count() > 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testFriendRequests);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testFriendRequests);
            }

            // Reject a request and make friend
            var rejectFriendRequest = repo.RejectFriendRequest(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(rejectFriendRequest);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(rejectFriendRequest);
            }

            /*
             * // Now no friend request
             * var friendInfo = repo.GetFriendRequest(userId, friendId);
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.Null(friendInfo);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(friendInfo);
             */

            // The are not friend
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.False(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(alreadyFriend);
            }
        }
Example #27
0
        public void SetUp()
        {
            converter = new CustomerConverter();

            fakeEntity = new Customer
            {
                Id            = NumberFaker.Number(1, int.MaxValue),
                Name          = StringFaker.Alpha(25),
                StreetAddress = new Address
                {
                    Address1   = LocationFaker.Street(),
                    Address2   = LocationFaker.Street(),
                    City       = LocationFaker.City(),
                    State      = StringFaker.Alpha(2),
                    PostalCode = LocationFaker.PostCode(),
                    Country    = LocationFaker.Country()
                },
                BillingAddress = new Address
                {
                    Address1   = LocationFaker.Street(),
                    Address2   = LocationFaker.Street(),
                    City       = LocationFaker.City(),
                    State      = StringFaker.Alpha(2),
                    PostalCode = LocationFaker.PostCode(),
                    Country    = LocationFaker.Country()
                },
                OfficePhone1   = PhoneFaker.Phone(),
                OfficePhone2   = PhoneFaker.Phone(),
                OfficeFax      = PhoneFaker.Phone(),
                Email          = InternetFaker.Email(),
                PrimaryContact = new HumanContact
                {
                    FirstName = NameFaker.FirstName(),
                    LastName  = NameFaker.LastName(),
                    Email     = InternetFaker.Email(),
                    Fax       = PhoneFaker.Phone(),
                    Phone1    = PhoneFaker.Phone(),
                    Phone2    = PhoneFaker.Phone(),
                    Notes     = TextFaker.Sentence()
                },
                Notes = TextFaker.Sentences(5)
            };

            fakeViewModel = new CustomerViewModel
            {
                Id   = NumberFaker.Number(1, int.MaxValue),
                Name = StringFaker.Alpha(25),
                CanLicensePreReleaseVersions = BooleanFaker.Boolean(),
                StreetAddress = new Address
                {
                    Address1   = LocationFaker.Street(),
                    Address2   = LocationFaker.Street(),
                    City       = LocationFaker.City(),
                    State      = StringFaker.Alpha(2),
                    PostalCode = LocationFaker.PostCode(),
                    Country    = LocationFaker.Country()
                },
                BillingMatchesStreetAddress = BooleanFaker.Boolean(),
                BillingAddress = new Address
                {
                    Address1   = LocationFaker.Street(),
                    Address2   = LocationFaker.Street(),
                    City       = LocationFaker.City(),
                    State      = StringFaker.Alpha(2),
                    PostalCode = LocationFaker.PostCode(),
                    Country    = LocationFaker.Country()
                },
                OfficePhone1   = PhoneFaker.Phone(),
                OfficePhone2   = PhoneFaker.Phone(),
                OfficeFax      = PhoneFaker.Phone(),
                Email          = InternetFaker.Email(),
                PrimaryContact = new HumanContact
                {
                    FirstName = NameFaker.FirstName(),
                    LastName  = NameFaker.LastName(),
                    Email     = InternetFaker.Email(),
                    Fax       = PhoneFaker.Phone(),
                    Phone1    = PhoneFaker.Phone(),
                    Phone2    = PhoneFaker.Phone(),
                    Notes     = TextFaker.Sentence()
                },
                Notes = TextFaker.Sentences(5)
            };
        }
Example #28
0
        public static T SelectFrom <T>(params T[] array)
        {
            int num = NumberFaker.Number(0, (int)array.Length);

            return((T)array.GetValue(num));
        }
Example #29
0
 public void SetUp()
 {
     _randomWrapper = new RandomWrapper();
     _numberFaker   = new NumberFaker(_randomWrapper);
 }
Example #30
0
 public static bool Boolean()
 {
     return(NumberFaker.Number(2) == 1);
 }