Esempio n. 1
0
        public void Test_dataAdapter_create_article()
        {
            // Arrange
            utils.CleanTables();
            Tuple <string, string> userIds = utils.CreateUsers();
            IDataAccessAdapter     adapter = container.Resolve <IDataAccessAdapter>();
            string  test_title             = "test_title";
            string  test_body = "test_body";
            Article article   = adapter.Create <Article>();

            article.Title       = test_title;
            article.Body        = test_body;
            article.CreatedDate = DateTime.Now;
            article.AuthorId    = userIds.Item1;

            // Act
            adapter.Add <Article>(article);
            adapter.SaveChanges();
            List <Article> articleList    = adapter.GetEntities <Article>().ToList();
            Article        createdArticle = articleList[0];

            // Assert
            Assert.IsTrue(articleList.Count == 1);
            Assert.IsNotNull(createdArticle.AspNetUser);
            Assert.IsTrue(createdArticle.AuthorId == userIds.Item1);
            Assert.IsTrue(createdArticle.Likes.Count() == 0);
        }
Esempio n. 2
0
        public void Test_dataAdapter_create_user_and_otp()
        {
            // Arrange
            CleanTables();
            IDataAccessAdapter adapter = container.Resolve <IDataAccessAdapter>();
            User user = new User {
                UserId = "testUser"
            };
            Otp otp = new Otp {
                User = user, Password = "******", StartDate = DateTime.Now
            };

            // Act
            adapter.Add <User>(user);
            adapter.Add <Otp>(otp);
            adapter.SaveChanges();
            List <User> userList  = adapter.GetEntities <User>().ToList();
            User        addedUser = userList.SingleOrDefault(u => u.Id == user.Id);

            // Assert
            Assert.IsNotNull(addedUser);
            Assert.IsNotNull(addedUser.Otp);
        }
Esempio n. 3
0
        public void Test_dataAdapter_create_user()
        {
            // Arrange
            CleanTables();
            IDataAccessAdapter adapter = container.Resolve <IDataAccessAdapter>();
            User user = new User {
                UserId = "testUser"
            };

            // Act
            adapter.Add <User>(user);
            adapter.SaveChanges();
            List <User> userList = adapter.GetEntities <User>().ToList();

            // Assert
            Assert.IsTrue(userList.Count == 1);
        }
Esempio n. 4
0
 public virtual TEntity Add(TEntity entity)
 {
     return(_dataAccessAdapter.Add(entity));
 }