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); } }
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); } }
public void TextFakerTest() { DisplayAndExecute(new Expression <Func <string> >[] { () => TextFaker.Sentence(), () => TextFaker.Sentences(4), }); }
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); }
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); } }
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); } }
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); }
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 GetPostByIDTest() { 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; 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 foundPost = postBll.GetPostByID(post.Id); if (TestingConfig.XUnit) { Xunit.Assert.NotNull(foundPost); } else { Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(foundPost); } var test = foundPost.Id.Equals(post.Id); if (TestingConfig.XUnit) { Xunit.Assert.True(test); } else { Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test); } }
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); } }
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() }; }
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) }; }
public static string Sentence() { return(TextFaker.Sentences(1)); }