public async Task AddAndRetrieve_MultipleSimpleObjects_Success()
        {
            var unitOfWork = new UserUnitOfWork(Database, CollectionName);

            var person1 = new UserAggregate()
            {
                FirstName = "John",
                Surname   = "Smith"
            };
            var person2 = new UserAggregate()
            {
                FirstName = "Jane",
                Surname   = "Doe"
            };

            unitOfWork.Users.Add(person1);
            unitOfWork.Users.Add(person2);
            await unitOfWork.CommitAsync();

            var person1Result = await unitOfWork.Users.QuerySingleAsync(user => user.Id == person1.Id);

            var person2Result = await unitOfWork.Users.QuerySingleAsync(user => user.Id == person2.Id);

            Assert.IsNotNull(person1Result);
            Assert.IsNotNull(person2Result);
        }
Ejemplo n.º 2
0
        public async Task MongoDelta_ReplaceStrategy()
        {
            var unitOfWork = new UserUnitOfWork(_database, _collectionName);

            var records = await unitOfWork.Users.QueryAsync(query => query.Take(NumberOfRecords));

            foreach (var record in records)
            {
                ModifyUserRecord(record);
            }

            await unitOfWork.CommitAsync();
        }
        public async Task MongoDelta()
        {
            var collectionName = Guid.NewGuid().ToString();
            var unitOfWork     = new UserUnitOfWork(_database, collectionName);

            for (var i = 0; i < NumberOfRecords; i++)
            {
                unitOfWork.Users.Add(new UserModel());
            }
            await unitOfWork.CommitAsync();

            await _database.DropCollectionAsync(collectionName);
        }
Ejemplo n.º 4
0
        public async Task AddAndUpdate_SimpleObject_Success()
        {
            var testUser = await UserAggregate.AddTestUser(Database, CollectionName);

            var unitOfWork = new UserUnitOfWork(Database, CollectionName);
            var model      = await unitOfWork.Users.QuerySingleAsync(user => user.Id == testUser.Id);

            model.FirstName = "Bobby";
            await unitOfWork.CommitAsync();

            var updateQuery = await unitOfWork.Users.QuerySingleAsync(user => user.FirstName == "Bobby");

            Assert.IsNotNull(updateQuery);
        }
Ejemplo n.º 5
0
        public async Task AddAndRemove_SimpleObject_Success()
        {
            var testUser = await UserAggregate.AddTestUser(Database, CollectionName);

            var unitOfWork = new UserUnitOfWork(Database, CollectionName);
            var model      = await unitOfWork.Users.QuerySingleAsync(user => user.Id == testUser.Id);

            unitOfWork.Users.Remove(model);
            await unitOfWork.CommitAsync();

            var removeQueryResult = await unitOfWork.Users.QuerySingleAsync(user => user.FirstName == "John");

            Assert.IsNull(removeQueryResult);
        }
        public async Task MongoDelta_ReplaceStrategy()
        {
            var unitOfWork = new UserUnitOfWork(_database, _collectionName);

            var records = await unitOfWork.DeltaUsers.QueryAsync(query => query.Take(NumberOfRecords));

            foreach (var record in records)
            {
                record.DisplayName = Guid.NewGuid().ToString();
                record.EmailAddress.EmailAddress = Guid.NewGuid().ToString();
                record.EmailAddress.Verified     = !record.EmailAddress.Verified;
            }

            await unitOfWork.CommitAsync();
        }
        public async Task AddAndRetrieve_SimpleObject_Success()
        {
            var unitOfWork = new UserUnitOfWork(Database, CollectionName);

            unitOfWork.Users.Add(new UserAggregate()
            {
                FirstName = "John",
                Surname   = "Smith"
            });
            await unitOfWork.CommitAsync();

            var queryResult = await unitOfWork.Users.QuerySingleAsync(user => user.FirstName == "John");

            Assert.IsNotNull(queryResult);
        }