Exemple #1
0
        public void TestTriggerBeforeDelete()
        {
            var instance1 = new TriggerClass {
                Data = Guid.NewGuid().ToString()
            };

            _databaseInstance.SaveAsync <TriggerClass, int>(instance1).Wait();
            var key2 = _databaseInstance.SaveAsync <TriggerClass, int>(new TriggerClass
            {
                Id = TriggerClassTestTrigger.BADDELETE, Data = Guid.NewGuid().ToString()
            }).Result;

            _databaseInstance.DeleteAsync(instance1).Wait(); // should be no problem

            var handled = false;

            try
            {
                _databaseInstance.DeleteAsync(typeof(TriggerClass), key2).Wait();
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Single() is SterlingTriggerException)
                {
                    handled = true;
                }
            }

            Assert.True(handled); //Trigger failed to throw exception for delete operation on key = 5.");
        }
Exemple #2
0
        public void TestTriggerAfterSave()
        {
            var target = new TriggerClass {
                Data = Guid.NewGuid().ToString(), IsDirty = true
            };

            _databaseInstance.SaveAsync <TriggerClass, int>(target).Wait();
            Assert.False(target.IsDirty); //Trigger failed: is dirty flag was not reset.");
        }