//.################################################
//# Copyright © 2006-2010 Evolving Software Ltd   #
//# Author: Vijay Patel                           #
//################################################'

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

using Evolving.DomainTypes;
using Evolving.TrueView.Domain.Attributes;

namespace TestApplicationDomainModel
{
    /// <summary>
    /// A set of Exception handling
    /// </summary>
    [Serializable]
    public class ExceptionTests
    {
        public Guid ID { get; internal set; }

        private bool _Bool = false;

        /// <summary>
        /// This should throw a single exception when the value is set to "Do it!"
        /// </summary>
        [Boolean(TrueValue = "Do it!", FalseValue = "Don't do it!")]
        public bool ThrowExceptionIfTrue
        {
            get { return _Bool; }
            set
            {
                _Bool = value;
                if (_Bool)
                {
                    throw new ApplicationException("This is a forced exception");
                }
            }
        }

        /// <summary>
        /// This should throw a single exception when the value is set to "Do it!"
        /// </summary>
        [Boolean(TrueValue = "Do it!", FalseValue = "Don't do it!", IsThreadSafe = false)]
        public bool ThrowExceptionIfTrue_Synchronous
        {
            get { return _Bool; }
            set
            {
                _Bool = value;
                if (_Bool)
                {
                    throw new ApplicationException("This is a forced exception");
                }
            }
        }


        public string ThrowAnException()
        {
            throw new ApplicationException("This is a forced exception");

            return System.Reflection.MethodBase.GetCurrentMethod().Name;
        }
    }
}
