コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
        public void GetManyByIdAsync_ItemsDoNotExist_ReturnsEmptyCollection()
        {
            MongoDbContext dbContext = RepositoryTestUtils.CreateDbContext();

            dbContext.InsertAsync(DbSchema.WorkspaceContainer, DbModelUtils.GetWorkspaceDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.WorkspaceContainer, DbModelUtils.GetWorkspaceDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.WorkspaceContainer, DbModelUtils.GetWorkspaceDbModel()).Wait();
            IEnumerable <string> ids = new string[2] {
                "1", "2"
            };

            WorkspaceRepository            workspaceRepository = new WorkspaceRepository();
            IEnumerable <WorkspaceDbModel> result = workspaceRepository.GetManyByIdAsync(dbContext, ids).Result;

            Assert.AreEqual(0, result.Count());
        }
コード例 #4
0
        public void GetManyByIdAsync_ItemsExist_ReturnsCollection()
        {
            MongoDbContext   dbContext         = RepositoryTestUtils.CreateDbContext();
            WorkspaceDbModel workspaceDbModel1 = DbModelUtils.GetWorkspaceDbModel();

            dbContext.InsertAsync(DbSchema.WorkspaceContainer, workspaceDbModel1).Wait();
            WorkspaceDbModel workspaceDbModel2 = DbModelUtils.GetWorkspaceDbModel();

            dbContext.InsertAsync(DbSchema.WorkspaceContainer, workspaceDbModel2).Wait();

            dbContext.InsertAsync(DbSchema.WorkspaceContainer, DbModelUtils.GetWorkspaceDbModel()).Wait();
            dbContext.InsertAsync(DbSchema.WorkspaceContainer, DbModelUtils.GetWorkspaceDbModel()).Wait();

            IEnumerable <string> ids = new string[2] {
                workspaceDbModel1.Id, workspaceDbModel2.Id
            };

            WorkspaceRepository     workspaceRepository = new WorkspaceRepository();
            List <WorkspaceDbModel> result = workspaceRepository.GetManyByIdAsync(dbContext, ids).Result.ToList();

            Assert.AreEqual(2, result.Count());
            Assert.IsNotNull(result.SingleOrDefault(x => x.Id == workspaceDbModel1.Id));
            Assert.IsNotNull(result.SingleOrDefault(x => x.Id == workspaceDbModel2.Id));
        }