コード例 #1
0
ファイル: Policy.cs プロジェクト: meowweijie/AOOAD_Assignment
 //Constructor
 public Policy()
 {
     PolicyNo        = string.Format("P{0:0000}", policyCounter);
     activeState     = new Active(this);
     lapsedState     = new Lapsed(this);
     terminatedState = new Terminated(this);
     ++policyCounter;
 }
コード例 #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)));
        }
コード例 #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));
        }
コード例 #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
            });
        }
コード例 #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");
            }
        }
コード例 #6
0
ファイル: Policy.cs プロジェクト: meowweijie/AOOAD_Assignment
 // State Pattern methods
 public void SetState(PolicyState state)
 {
     this.state = state;
 }
コード例 #7
0
 public Policy(List <PolicyCategory> policyProfiles, string title)
 {
     m_PolicyProfiles = policyProfiles;
     m_Title          = title;
     m_Policystate    = PolicyState.Enabled;
 }
コード例 #8
0
 public Policy()
 {
     m_PolicyProfiles = new List <PolicyCategory>();
     m_Title          = string.Empty;
     m_Policystate    = PolicyState.Disabled;
 }