C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Test_DataTypes.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using AnalyzeRe;
6
7#if MSTEST
8using Microsoft.VisualStudio.TestTools.UnitTesting;
9#elif NUNIT
10using NUnit.Framework;
11using TestClass = NUnit.Framework.TestFixtureAttribute;
12using TestMethod = NUnit.Framework.TestAttribute;
13#endif
14
16{
21 [TestClass]
23 {
24 [TestMethod]
26 {
27 Policy first = Samples.Policy;
28 Assert.IsTrue(first.Equals(first));
29 Policy second = Samples.Policy.DeepCopy();
30 Assert.IsTrue(first.Equals(second));
31 Assert.IsTrue(second.Equals(first));
32 Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
33
35 Assert.IsFalse(first.Equals(second));
36 Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
37
39 Assert.IsFalse(first.Equals(second));
40 Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
41
42 // Assert that order of RecordType lists doesn't matter
43 first = new Policy
44 {
45 transform_records = new HashSet<RecordType> { RecordType.Loss, RecordType.FixedExpense }
46 };
47 second = new Policy
48 {
49 transform_records = new HashSet<RecordType> { RecordType.FixedExpense, RecordType.Loss }
50 };
51 Assert.IsTrue(first.Equals(second));
52 Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
53
54 first.forward_records.Add(RecordType.ProportionalExpense);
55 second.forward_records.Add(RecordType.NoClaimsBonus);
56 Assert.IsFalse(first.Equals(second));
57 Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
58
59 first.forward_records.Add(RecordType.NoClaimsBonus);
60 second.forward_records.Add(RecordType.ProportionalExpense);
61 Assert.IsTrue(first.Equals(second));
62 Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
63 }
64
65 [TestMethod]
66 public void Test_Fee_Equatable()
67 {
69 Assert.IsTrue(first.Equals(first));
70 Fee second = first.DeepCopy();
71 Assert.IsTrue(first.Equals(second));
72 Assert.IsTrue(second.Equals(first));
73 Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
74
75 second = Samples.Fees.FixedExpense;
76 Assert.IsFalse(first.Equals(second));
77 Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
78
80 Assert.IsFalse(first.Equals(second));
81 Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
82
83 // Assert that order of fee reference lists doesn't matter
84 first = new ProfitCommission
85 {
86 premiums = new List<FeeReference>{ FeeReference.Premium, FeeReference.ReinstatementPremium }
87 };
88 second = new ProfitCommission
89 {
90 premiums = new List<FeeReference> { FeeReference.ReinstatementPremium, FeeReference.Premium }
91 };
92 Assert.IsTrue(first.Equals(second));
93 Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
94 }
95
96 [TestMethod]
98 {
99 FeeReference empty = new FeeReference();
100 Assert.IsFalse(empty.Equals(null));
101 Assert.IsTrue(empty.Equals(empty));
102 Assert.IsTrue(empty.Equals(new FeeReference()));
103 Assert.AreEqual(empty.GetHashCode(), empty.GetHashCode());
104 Assert.AreEqual(empty.GetHashCode(), new FeeReference().GetHashCode());
105
107 Assert.IsFalse(sample.Equals(null));
108 Assert.IsFalse(sample.Equals(empty));
109 Assert.IsTrue(sample.Equals(sample));
110 Assert.IsTrue(sample.Equals(FeeReference.Losses));
111 Assert.AreEqual(sample.GetHashCode(), sample.GetHashCode());
112 Assert.AreEqual(sample.GetHashCode(), FeeReference.Losses.GetHashCode());
113 Assert.AreNotEqual(sample.GetHashCode(), empty.GetHashCode());
114
115 Assert.AreNotEqual(FeeReference.Losses, FeeReference.Premium);
121
128
130 Assert.AreEqual(FeeReference.CreateFromFeeName("Losses"), FeeReference.CreateFromFeeName("Losses"));
131 Assert.AreNotEqual(FeeReference.Losses, FeeReference.CreateFromFeeName("Losses"));
132 Assert.AreNotEqual(FeeReference.CreateFromPremiumOrLossName("Losses"), FeeReference.CreateFromFeeName("Losses"));
133 }
134
135 [TestMethod]
137 {
139 Assert.IsFalse(empty.Equals(null));
140 Assert.IsTrue(empty.Equals(empty));
141 Assert.IsTrue(empty.Equals(new DelayedPayment.Payment()));
142 Assert.AreEqual(empty.GetHashCode(), empty.GetHashCode());
143 Assert.AreEqual(empty.GetHashCode(), new DelayedPayment.Payment().GetHashCode());
144
145 DelayedPayment.Payment sample = new DelayedPayment.Payment(123, 0.123);
146 Assert.IsFalse(sample.Equals(null));
147 Assert.IsFalse(sample.Equals(empty));
148 Assert.IsTrue(sample.Equals(sample));
149 Assert.IsTrue(sample.Equals(new DelayedPayment.Payment(123, 0.123)));
150 Assert.AreEqual(sample.GetHashCode(), sample.GetHashCode());
151 Assert.AreEqual(sample.GetHashCode(), new DelayedPayment.Payment(123, 0.123).GetHashCode());
152 Assert.AreNotEqual(sample.GetHashCode(), empty.GetHashCode());
153 }
154 }
155}
static ProportionalExpense ProportionalExpense
Definition Samples.cs:64
static FixedExpense FixedExpense
Definition Samples.cs:57
static ProfitCommission ProfitCommission
Definition Samples.cs:72
Exposes sample resource objects, with built-in methods for injecting dependencies.
Definition Samples.cs:14
static Policy TransformAllPolicy
Definition Samples.cs:121
static Policy Policy
Definition Samples.cs:113
static Policy ForwardAllPolicy
Definition Samples.cs:123
Test the MonetaryUnit by playing with the premium on a Layer_WithTerms object. This is a necessary sp...
Represents a reference, used in Fee objects.
static FeeReference Losses
Layer Losses Reference.
static FeeReference ReinstatementBrokerage
Reinstatement Brokerage Reference.
static FeeReference Premium
Premium reference.
bool Equals(FeeReference other)
Determine if this FeeReference is equivalent to another.
static FeeReference CreateFromFeeName(string name)
Create a reference to a Fee from its name.
override int GetHashCode()
Get the HashCode for this FeeReference.
static FeeReference ReinstatementPremium
Reinstatement Premium Reference.
static FeeReference CreateFromPremiumOrLossName(string name)
Create a reference to a Premium or Loss from its name.
Abstract representation of a fee. This resource type cannot be instantiated instead derived resource ...
Definition Fee.cs:14
bool Equals(Fee other)
override int GetHashCode()
Get the HashCode for this Fee.
Definition Fee.cs:41
The Profit Commission applies a fee that is the sum of the premium sources minus the sum of loss and ...
Describes a single payment, which consists of a delay and fracational amount.
bool Equals(Payment other)
Determine if this Payment is equivalent to another.
override int GetHashCode()
Get the HashCode for this Payment.
A "delayed payment" payment pattern models claims being paid in instalments at fixed delays after the...
Layer Policy is the rule on RecordType that determines how occurrences belonging to a particular Reco...
Definition Policy.cs:17
bool Equals(Policy other)
Determine if this Policy is equivalent to another.
override int GetHashCode()
Get the HashCode for this Policy.
Definition Policy.cs:55
HashSet< RecordType > forward_records
When a record type is listed under forward, all input occurrences with the matching record type are n...
Definition Policy.cs:29
RecordType
The type of occurrence.
Definition RecordType.cs:10