예제 #1
0
        public void TestTriggerOnChildren()
        {
            var trigger = new TriggerListTestTrigger(100);

            _databaseInstance.RegisterTrigger(trigger);
            var expected = TestListModel.MakeTestListModel();

            // set all the keys to something negative so the trigger can generate the key
            foreach (var subModel in expected.Children)
            {
                subModel.Key = -1 * subModel.Key;
            }

            var key = _databaseInstance.SaveAsync(expected).Result;

            var actual = _databaseInstance.LoadAsync <TestListModel>(key).Result;

            Assert.NotNull(actual.Children);     //Trigger failed: child list is null.");
            Assert.Equal(expected.Children.Count,
                         actual.Children.Count); //Trigger failed: actual child count different.");

            var noKey = (from m in actual.Children where m == null || m.Key < 1 select m).Any();

            Assert.False(noKey); //Trigger failed: children found without a key.");
            _databaseInstance.UnregisterTrigger(trigger);
        }
예제 #2
0
        public void StartService()
        {
            _engine = new SterlingEngine();

            if (Debugger.IsAttached)
            {
                _logger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            _engine.Activate();
            Database = _engine.SterlingDatabase.RegisterDatabase<BizcardDatabase>(_driver);
            Database.RegisterTrigger(new IdentityTrigger<Contact>(Database));
            Database.RegisterTrigger(new IdentityTrigger<Group>(Database));

            Current = this;
        }
예제 #3
0
        /// <summary>
        ///     Check to see if the database has been populated. If not, populate it.
        /// </summary>
        /// <param name="database">The database instance</param>
        public static void CheckAndCreate(ISterlingDatabaseInstance database)
        {
            // register the triggers
            database.RegisterTrigger(new IdentityTrigger <ReputationModel>(database));
            database.RegisterTrigger(new IdentityTrigger <LoginCredentialModel>(database));
            database.RegisterTrigger(new IdentityTrigger <ProfileModel>(database));

            // if any are here we've already set things up because users can't delete these
            if (database.Query <ReputationModel, int>().Any())
            {
                return;
            }

            // get rid of old data
            database.Truncate(typeof(ReputationModel));
            database.Truncate(typeof(LoginCredentialModel));

            database.Flush();
        }
예제 #4
0
        public void TestInit()
        {
            _engine = Factory.NewEngine();
            _engine.Activate();
            _databaseInstance = _engine.SterlingDatabase.RegisterDatabase <TriggerDatabase>(TestContext.TestName, GetDriver());
            _databaseInstance.PurgeAsync().Wait();

            // get the next key in the database for auto-assignment
            var nextKey = _databaseInstance.Query <TriggerClass, int>().Any() ?
                          (from keys in _databaseInstance.Query <TriggerClass, int>()
                           select keys.Key).Max() + 1 : 1;

            _databaseInstance.RegisterTrigger(new TriggerClassTestTrigger(nextKey));
        }
        public void ActivateEngine()
        {
            _engine = new SterlingEngine();
            _engine.SterlingDatabase.RegisterSerializer<DefaultSerializer>();
            _logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
            _engine.Activate();

            _database = _engine.SterlingDatabase.RegisterDatabase<CoachesDatabase>(new IsolatedStorageDriver());

            _database.RegisterTrigger(new IdentityTrigger<EventDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<PracticeDrillDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<TeamDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<LocationDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<PlayerDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<SportDto>(_database));
        }