Ejemplo n.º 1
0
        public void GetByAuthIdAsync_ItemDoesNotExist_ReturnsNull()
        {
            MongoDbContext dbContext = RepositoryTestUtils.CreateDbContext();

            dbContext.InsertAsync(DbSchema.UserContainer, DbModelUtils.GetUserDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.UserContainer, DbModelUtils.GetUserDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.UserContainer, DbModelUtils.GetUserDbModel()).Wait();
            string authId = Guid.NewGuid().ToString();

            UserRepository userRepository = new UserRepository();
            UserDbModel    result         = userRepository.GetByAuthIdAsync(dbContext, authId).Result;

            Assert.IsNull(result);
        }
Ejemplo n.º 2
0
        public void GetByIdAsync_ItemDoesExist_ReturnsSingleItem()
        {
            MongoDbContext dbContext   = RepositoryTestUtils.CreateDbContext();
            UserDbModel    userDbModel = DbModelUtils.GetUserDbModel();

            dbContext.InsertAsync(DbSchema.UserContainer, userDbModel).Wait();
            dbContext.InsertAsync(DbSchema.UserContainer, DbModelUtils.GetUserDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.UserContainer, DbModelUtils.GetUserDbModel()).Wait();

            UserRepository userRepository = new UserRepository();
            UserDbModel    result         = userRepository.GetByIdAsync(dbContext, userDbModel.Id).Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(userDbModel.Id, result.Id);
            Assert.AreEqual(userDbModel.UserName, result.UserName);
        }