private void CreateUserWithFormat(MembershipPasswordFormat format)
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", format.ToString());
            provider.Initialize(null, config);

            // create the user
            MembershipCreateStatus status;

            provider.CreateUser("foo", "barbar!", "*****@*****.**", null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            // verify that the password format was saved
            var filter = new MongoDB.Driver.FilterDefinitionBuilder <User>();

            var user = IAsyncCursorExtensions.First(_db.GetCollection <User>(provider.CollectionName).FindSync <User>(filter.Eq(provider.ElementNames.LowercaseUsername, "foo")));

            MembershipPasswordFormat rowFormat = user.PasswordFormat;

            Assert.AreEqual(format, rowFormat);

            //  then attempt to verify the user
            Assert.IsTrue(provider.ValidateUser("foo", "barbar!"));
        }
Пример #2
0
        public async void UpdateBatch(int amount = 1000)
        {
            var studentsCollection = database.GetCollection<Student>("Students");
            var filterDefinitionBuilder = new MongoDB.Driver.FilterDefinitionBuilder<Student>();


            var updateDefinitionBuilder = new UpdateDefinitionBuilder<Student>();
            var updateDefinition = updateDefinitionBuilder.Inc(x => x.Age, 1);
            await studentsCollection.UpdateManyAsync(new FilterDefinitionBuilder<Student>().Exists((Student x) => x.Id, true), updateDefinition);
            for (var i = 0; i < amount; i++)
            {
                var filterDefinitino = filterDefinitionBuilder.Eq<string>((Student x) => x.Id, $"Students/{i}");
                var students = await studentsCollection.Find<Student>(filterDefinitino, new FindOptions
                {
                    CursorType = CursorType.NonTailable,


                }).ToListAsync();
                                
                if (students.Count == 0 || students.Count != 1 || students[0].Id != $"Students/{i}")
                {
                    throw new Exception("Errorous Read");
                }

            }
        }
Пример #3
0
        public Task <List <PlaceModel> > GetListBySubscriber(Guid id)
        {
            var collection = _SettingsModel.GetCollection <PlaceModel>(collectionName);

            var filter = new MongoDB.Driver.FilterDefinitionBuilder <PlaceModel>().Eq(x => x.SubscriberId, id);

            return(collection.Find(filter).ToListAsync());
        }
Пример #4
0
        public async Task <long> Delete(Guid[] ids)
        {
            var collection = _SettingsModel.GetCollection <PlaceModel>(collectionName);

            var filter = new MongoDB.Driver.FilterDefinitionBuilder <PlaceModel>().In(x => x.Id, ids);

            var tasks = await collection.DeleteManyAsync(filter);

            return(tasks.DeletedCount);
        }
Пример #5
0
        public async Task Read(int amount = 1000)
        {            
            var filterDefinitionBuilder = new MongoDB.Driver.FilterDefinitionBuilder<Student>();

            for(var i=0; i<amount; i++)
            {
                var filterDefinitino = filterDefinitionBuilder.Eq<string>((Student x) => x.Id , $"Students/{i}");
                var students = await studentsCollection.Find<Student>(filterDefinitino, new FindOptions
                {
                    CursorType = CursorType.NonTailable,


                }).ToListAsync();
                

                if (students.Count ==0 || students.Count !=1 || students[0].Id != $"Students/{i}")
                {
                    throw new Exception("Errorous Read");
                }

            }            
        }
Пример #6
0
 private PersonsRepository()
 {
     builder = Builders <T> .Filter;
     Storage = MongoDbStorage <T> .Instance;
 }