Ejemplo n.º 1
0
 //Constructor
 public Policy()
 {
     PolicyNo        = string.Format("P{0:0000}", policyCounter);
     activeState     = new Active(this);
     lapsedState     = new Lapsed(this);
     terminatedState = new Terminated(this);
     ++policyCounter;
 }
Ejemplo n.º 2
0
        public Task <Response <PolicyState> > PolicyGetAsync(string policyId)
        {
            var state = new PolicyState()
            {
                Amount       = 100000,
                BusinessTime = DateTimeOffset.Now,
                Duration     = 100,
                Id           = policyId
            };

            return(Task.FromResult(ResponseCodes.OK(state)));
        }
Ejemplo n.º 3
0
        public Task <Response <ICollection <PolicyState> > > PolicyGetAsync()
        {
            var state = new PolicyState()
            {
                Amount       = 100000,
                BusinessTime = DateTimeOffset.Now,
                Duration     = 100,
                Id           = "1"
            };
            var response = new Response <ICollection <PolicyState> >(200, new Dictionary <string, IEnumerable <string> >
            {
                { "Access-Control-Allow-Origin", new [] { "*" } }
            }, new [] { state });

            return(Task.FromResult(response));
        }
Ejemplo n.º 4
0
        public void Given_policy_snapshot_When_restoring_Then_it_succeed()
        {
            var snapshot = new PolicyState
            {
                Amount       = 5,
                BusinessTime = DateTimeOffset.Now,
                Duration     = TimeSpan.FromDays(1),
                ExpiryDate   = DateTimeOffset.Now.AddDays(10),
                IsExpired    = false,
                Issued       = true,
                IssueDate    = DateTimeOffset.Now
            };
            var policy = new InsurancePolicy();

            policy.RestoreFromSnapshot(new SnapshotState <PolicyState>
            {
                State   = snapshot, Address = new AggregateAddress <InsurancePolicy>(), Id = Guid.NewGuid().ToString(),
                Version = 100
            });
        }
Ejemplo n.º 5
0
        public void GetByState(PolicyState state)
        {
            var now = DateTime.Now;

            switch (state)
            {
            case PolicyState.Pending:
                AttachCondition(e => e.StartDate > now);
                break;

            case PolicyState.Active:
                AttachCondition(e => e.EndDate >= now && e.StartDate <= now);
                break;

            case PolicyState.Expired:
                AttachCondition(e => e.EndDate < now);
                break;

            default:
                throw new NotImplementedException("Cannot define policy state");
            }
        }
Ejemplo n.º 6
0
 // State Pattern methods
 public void SetState(PolicyState state)
 {
     this.state = state;
 }
Ejemplo n.º 7
0
 public Policy(List <PolicyCategory> policyProfiles, string title)
 {
     m_PolicyProfiles = policyProfiles;
     m_Title          = title;
     m_Policystate    = PolicyState.Enabled;
 }
Ejemplo n.º 8
0
 public Policy()
 {
     m_PolicyProfiles = new List <PolicyCategory>();
     m_Title          = string.Empty;
     m_Policystate    = PolicyState.Disabled;
 }