public void AddRegularSubject()
        {
            // Arrange
            SubjectRepository subjectRepository = new SubjectRepository(dbContext);
            Subject           subject           = new Subject {
                Name = Convert.ToString(TestContext.DataRow["Name"])
            };

            // Act
            subjectRepository.Insert(subject);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Subjects.ToList(), subject);
        }
Esempio n. 2
0
        public void GetAllColumnsOfSubject()
        {
            // Arrange
            Subject expectedSubject = new Subject
            {
                Name     = "Some test name",
                Messages = new List <Message>
                {
                    new Message
                    {
                        Date = DateTime.Now,
                        Text = "Some test text",
                        User = dbContext.Users.First(),
                    },
                    new Message
                    {
                        Date = DateTime.Now,
                        Text = "Some other test text",
                        User = dbContext.Users.First()
                    }
                }
            };

            // Act
            dbContext.Subjects.Add(expectedSubject);
            dbContext.SaveChanges();
            Subject actualSubject = dbContext.Subjects.Find(expectedSubject.Id);

            // Assert
            Assert.AreEqual(expectedSubject.Name, actualSubject.Name);
            Assert.AreEqual(expectedSubject.Messages, actualSubject.Messages);
        }
Esempio n. 3
0
        public void GetAllColumnsOfComment()
        {
            // Arrange
            User    user            = dbContext.Users.First();
            Comment expectedComment = new Comment
            {
                Date  = DateTime.Now,
                Text  = "Some test text",
                User  = user,
                Photo = dbContext.Photos.First(),
                Likes = new List <CommentLike>
                {
                    new CommentLike {
                        IsLiked = true, User = user
                    },
                    new CommentLike {
                        IsLiked = false, User = dbContext.Users.ToArray()[1]
                    }
                }
            };

            // Act
            dbContext.Comments.Add(expectedComment);
            dbContext.SaveChanges();
            Comment actualComment = dbContext.Comments.Find(expectedComment.Id);

            // Assert
            Assert.AreEqual(expectedComment.Date, actualComment.Date);
            Assert.AreEqual(expectedComment.Text, actualComment.Text);
            Assert.AreEqual(expectedComment.User, actualComment.User);
            Assert.AreEqual(expectedComment.Photo, actualComment.Photo);
            CollectionAssert.AreEqual(expectedComment.Likes.ToArray(), actualComment.Likes.ToArray());
        }
Esempio n. 4
0
        public void AddPhoto()
        {
            // Arrange
            PhotoRepository photoRepository = new PhotoRepository(dbContext);
            Photo           photo           = new Photo
            {
                User = dbContext.Users.First(),
                Path = "1/4.jpg"
            };

            // Act
            photoRepository.Insert(photo);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Photos.ToList(), photo);
        }
        public void AddCommentLike()
        {
            // Arrange
            CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext);
            CommentLike           commentLike           = new CommentLike
            {
                User    = dbContext.Users.First(),
                Comment = dbContext.Comments.First(),
                IsLiked = true
            };

            // Act
            commentLikeRepository.Insert(commentLike);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.CommentLike.ToList(), commentLike);
        }
        public void AddPhotoLike()
        {
            // Arrange
            PhotoLikeRepository photoLikeRepository = new PhotoLikeRepository(dbContext);
            PhotoLike           photoLike           = new PhotoLike
            {
                User    = dbContext.Users.First(),
                Photo   = dbContext.Photos.First(),
                IsLiked = true
            };

            // Act
            photoLikeRepository.Insert(photoLike);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.PhotoLike.ToList(), photoLike);
        }
Esempio n. 7
0
        public void AddMessage()
        {
            // Arrange
            MessageRepository messageRepository = new MessageRepository(dbContext);
            Message           message           = new Message
            {
                Date    = System.DateTime.Now,
                User    = dbContext.Users.First(),
                Subject = dbContext.Subjects.First(),
                Text    = "Test test test test test test test"
            };

            // Act
            messageRepository.Insert(message);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Messages.ToList(), message);
        }
        public void AddComment()
        {
            // Arrange
            CommentRepository commentRepository = new CommentRepository(dbContext);
            Comment           comment           = new Comment
            {
                Date  = System.DateTime.Now,
                User  = dbContext.Users.First(),
                Photo = dbContext.Photos.First(),
                Text  = "Test test test test test test test"
            };

            // Act
            commentRepository.Insert(comment);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Comments.ToArray(), comment);
        }
        public void AddRegularUserWithoutAvatar()
        {
            // Arrange
            UserRepository userRepository = new UserRepository(dbContext);
            User           user           = new User()
            {
                NickName = "John", Password = "******"
            };

            // Act
            userRepository.Insert(user);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Users.ToList(), user);
        }
Esempio n. 10
0
        public void GetAllColumnsOfPhoto()
        {
            // Arrange
            User  user          = dbContext.Users.First();
            Photo expectedPhoto = new Photo
            {
                Path  = "Some test path.jpg",
                User  = user,
                Likes = new List <PhotoLike>
                {
                    new PhotoLike {
                        IsLiked = true, User = user
                    },
                    new PhotoLike {
                        IsLiked = false, User = dbContext.Users.ToArray()[1]
                    }
                },
                Comments = new List <Comment>
                {
                    new Comment
                    {
                        Date  = DateTime.Now,
                        Text  = "Some test text",
                        User  = user,
                        Likes = new List <CommentLike>
                        {
                            new CommentLike {
                                IsLiked = true, User = user
                            },
                            new CommentLike {
                                IsLiked = false, User = dbContext.Users.ToArray()[1]
                            }
                        }
                    }
                }
            };

            // Act
            dbContext.Photos.Add(expectedPhoto);
            dbContext.SaveChanges();
            Photo actualPhoto = dbContext.Photos.Find(expectedPhoto.Id);

            // Assert
            Assert.AreEqual(expectedPhoto.Path, actualPhoto.Path);
            Assert.AreEqual(expectedPhoto.User, actualPhoto.User);
            CollectionAssert.AreEqual(expectedPhoto.Likes.ToArray(), actualPhoto.Likes.ToArray());
            CollectionAssert.AreEqual(expectedPhoto.Comments.ToArray(), actualPhoto.Comments.ToArray());
        }
Esempio n. 11
0
        public void GetAllColumnsOfPhotoLike()
        {
            // Arrange
            PhotoLike expectedPhotoLike = new PhotoLike
            {
                IsLiked = true,
                User    = dbContext.Users.First(),
                Photo   = dbContext.Photos.First()
            };

            // Act
            dbContext.PhotoLike.Add(expectedPhotoLike);
            dbContext.SaveChanges();
            PhotoLike actualPhotoLike = dbContext.PhotoLike.Find(expectedPhotoLike.Id);

            // Assert
            Assert.AreEqual(expectedPhotoLike.IsLiked, actualPhotoLike.IsLiked);
            Assert.AreEqual(expectedPhotoLike.User, actualPhotoLike.User);
            Assert.AreEqual(expectedPhotoLike.Photo, actualPhotoLike.Photo);
        }
Esempio n. 12
0
        public void GetAllColumnsOfCommentLike()
        {
            // Arrange
            CommentLike expectedCommentLike = new CommentLike
            {
                IsLiked = true,
                User    = dbContext.Users.First(),
                Comment = dbContext.Comments.First()
            };

            // Act
            dbContext.CommentLike.Add(expectedCommentLike);
            dbContext.SaveChanges();
            CommentLike actualCommentLike = dbContext.CommentLike.Find(expectedCommentLike.Id);

            // Assert
            Assert.AreEqual(expectedCommentLike.IsLiked, actualCommentLike.IsLiked);
            Assert.AreEqual(expectedCommentLike.User, actualCommentLike.User);
            Assert.AreEqual(expectedCommentLike.Comment, actualCommentLike.Comment);
        }
Esempio n. 13
0
        public void GetAllColumnsOfMessage()
        {
            // Arrange
            Message expectedMessage = new Message
            {
                Date    = DateTime.Now,
                Text    = "Some test text",
                User    = dbContext.Users.First(),
                Subject = dbContext.Subjects.First()
            };

            // Act
            dbContext.Messages.Add(expectedMessage);
            dbContext.SaveChanges();
            Message actualMessage = dbContext.Messages.Find(expectedMessage.Id);

            // Assert
            Assert.AreEqual(expectedMessage.Date, actualMessage.Date);
            Assert.AreEqual(expectedMessage.Text, actualMessage.Text);
            Assert.AreEqual(expectedMessage.User, actualMessage.User);
            Assert.AreEqual(expectedMessage.Subject, actualMessage.Subject);
        }
Esempio n. 14
0
        public void AddRegularUserWithoutAvatar()
        {
            // Arrange
            User user = new User()
            {
                NickName = "John", Password = "******"
            };

            User[] users = new User[]
            {
                new User()
                {
                    NickName = "Adam", Password = "******"
                },
                new User()
                {
                    NickName = "Braxton", Password = "******"
                },
                new User()
                {
                    NickName = "Boyle", Password = "******"
                },
                new User()
                {
                    NickName = "Jarred", Password = "******"
                },
            };

            // Act
            dbContext.Users.Add(user);
            dbContext.Users.AddRange(users);
            dbContext.SaveChanges();

            // Assert
            CollectionAssert.Contains(dbContext.Users.ToList(), user);
            CollectionAssert.IsSubsetOf(users, dbContext.Users.ToArray());
        }
Esempio n. 15
0
 // METHODS
 /// <summary>
 /// Confirm all transaction to DataBase
 /// </summary>
 /// <returns>
 /// Amount of transaction that has been confirmed
 /// </returns>
 public int Save()
 {
     return(context.SaveChanges());
 }
Esempio n. 16
0
        public void GetAllColumnsOfUser()
        {
            // Arrange
            User  firstUser    = dbContext.Users.First();
            User  secondUser   = dbContext.Users.ToArray()[1];
            Photo photo        = dbContext.Photos.First();
            User  expectedUser = new User
            {
                MainPhotoPath = "Test main photo path.jpg",
                NickName      = "Test nickname",
                Password      = "******",
                IsAdmin       = false,
                Photos        = new List <Photo>
                {
                    new Photo
                    {
                        Path  = "Some test path.jpg",
                        Likes = new List <PhotoLike>
                        {
                            new PhotoLike {
                                IsLiked = true, User = firstUser
                            },
                            new PhotoLike {
                                IsLiked = false, User = secondUser
                            }
                        },
                        Comments = new List <Comment>
                        {
                            new Comment
                            {
                                Date  = DateTime.Now,
                                Text  = "Some test text",
                                User  = firstUser,
                                Likes = new List <CommentLike>
                                {
                                    new CommentLike {
                                        IsLiked = true, User = firstUser
                                    },
                                    new CommentLike {
                                        IsLiked = false, User = secondUser
                                    }
                                }
                            }
                        }
                    }
                },
                Followers = new List <User> {
                    firstUser, secondUser
                },
                Following = new List <User> {
                    firstUser, secondUser
                },
                Comments = new List <Comment>
                {
                    new Comment
                    {
                        Date  = DateTime.Now,
                        Text  = "Some test text",
                        Photo = photo,
                        Likes = new List <CommentLike>
                        {
                            new CommentLike {
                                IsLiked = true, User = firstUser
                            },
                            new CommentLike {
                                IsLiked = false, User = secondUser
                            }
                        }
                    }
                },
                PhotoLikes = new List <PhotoLike>
                {
                    new PhotoLike
                    {
                        IsLiked = true,
                        Photo   = photo
                    }
                },
                CommentLikes = new List <CommentLike>
                {
                    new CommentLike
                    {
                        IsLiked = true,
                        Comment = dbContext.Comments.First()
                    }
                },
                Messages = new List <Message>
                {
                    new Message
                    {
                        Date    = DateTime.Now,
                        Text    = "Some test text",
                        Subject = dbContext.Subjects.First()
                    }
                }
            };

            // Act
            dbContext.Users.Add(expectedUser);
            dbContext.SaveChanges();
            User actualUser = dbContext.Users.Find(expectedUser.Id);

            // Assert
            Assert.AreEqual(expectedUser.MainPhotoPath, actualUser.MainPhotoPath);
            Assert.AreEqual(expectedUser.NickName, actualUser.NickName);
            Assert.AreEqual(expectedUser.Password, actualUser.Password);
            Assert.AreEqual(expectedUser.IsAdmin, actualUser.IsAdmin);
            CollectionAssert.AreEqual(expectedUser.Photos.ToArray(), actualUser.Photos.ToArray());
            CollectionAssert.AreEqual(expectedUser.Followers.ToArray(), actualUser.Followers.ToArray());
            CollectionAssert.AreEqual(expectedUser.Following.ToArray(), actualUser.Following.ToArray());
            CollectionAssert.AreEqual(expectedUser.Comments.ToArray(), actualUser.Comments.ToArray());
            CollectionAssert.AreEqual(expectedUser.PhotoLikes.ToArray(), actualUser.PhotoLikes.ToArray());
            CollectionAssert.AreEqual(expectedUser.CommentLikes.ToArray(), actualUser.CommentLikes.ToArray());
            CollectionAssert.AreEqual(expectedUser.Messages.ToArray(), actualUser.Messages.ToArray());
        }