public void Given_policy_When_issuing_without_duration_Then_get_an_error() { var policy = new InsurancePolicy(); IAggregateRoot policyAggregate = policy; policyAggregate.Apply(new PolicyCreatedEvent()); policy.Invoking(async p => await p.Execute(new IssuePolicyCommand(policy.Address))) .Should().Throw <PolicyMissingDurationException>(); }
public void Given_a_policy_When_executing_command_for_another_instance_Then_getting_error() { var policy = new InsurancePolicy(); var id = Guid.NewGuid().ToString(); policy.Apply(new PolicyCreatedEvent(id)); policy.Invoking(async p => await p.Execute(new ProcessNewTimeCommand(Guid.NewGuid().ToString(), DateTimeOffset.Now))) .Should().Throw <AggregateIdMismatchException>(); }
public void Given_policy_with_duration_When_issuing_without_amount_Then_get_an_error() { var policy = new InsurancePolicy(); IAggregateRoot policyAggregate = policy; policyAggregate.Apply(new PolicyCreatedEvent()); policyAggregate.Apply(new PolicyDurationSetEvent(policy.Address.Id, TimeSpan.FromDays(1))); policy.Invoking(async p => await p.Execute(new IssuePolicyCommand(policy.Address))) .Should().Throw <PolicyZeroAmountException>(); }
public void Given_not_issued_policy_When_claiming_over_budget_Then_get_error() { var policy = new InsurancePolicy(); var id = Guid.NewGuid().ToString(); policy.Apply(new PolicyCreatedEvent(id), new PolicyDurationSetEvent(id, TimeSpan.FromDays(1)), new PolicyAmountSetEvent(id, 10m)); policy.Invoking(async p => await p.Execute(new ProcessClaimCommand(policy.Address, new Claim(1m)))) .Should().Throw <PolicyNotIssuedException>(); }
public void Given_a_policy_When_executing_unknown_command_Then_getting_error() { var policy = new InsurancePolicy(); var id = Guid.NewGuid().ToString(); policy.Apply(new PolicyCreatedEvent(id)); policy.Invoking( async p => await p.Execute(new SomeCommand { Destination = Address.New <InsurancePolicy>(id) })) .Should().Throw <UnsupportedCommandException>(); }
public void Given_expired_policy_When_claiming_within_budget_Then_getting_error() { var policy = new InsurancePolicy(); var id = Guid.NewGuid().ToString(); policy.Apply(new PolicyCreatedEvent(id), new PolicyDurationSetEvent(id, TimeSpan.FromDays(1)), new PolicyAmountSetEvent(id, 10m), new PolicyIssuedEvent(id, DateTimeOffset.Now), new PolicyTimePassedEvent(id, DateTimeOffset.Now.AddDays(1)), new PolicyExpiredEvent(id) ); policy.Invoking(async p => await p.Execute(new ProcessClaimCommand(policy.Address, new Claim(1m)))) .Should().Throw <PolicyExpiredException>(); }