2using System.Collections.Generic;
10using Microsoft.VisualStudio.TestTools.UnitTesting;
13using TestClass = NUnit.Framework.TestFixtureAttribute;
14using TestMethod = NUnit.Framework.TestAttribute;
15using TestCategory = NUnit.Framework.CategoryAttribute;
24 private const string Category =
"Test_Perspective";
26 #region Test Helper Methods
35#pragma warning disable 618
38 Perspective.Base.LossNetOfAggregateTerms
39#pragma warning restore 618
44 .Except(
new[] { Perspective.Base.NetLoss }).ToArray();
56 [Obsolete(
"Used to test legacy perspectives")]
62 foreach (
bool prem
in new List<bool> {
true,
false })
63 foreach (
bool reinstPrem
in new List<bool> {
true,
false })
64 foreach (
bool reinstBrok
in new List<bool> {
true,
false })
71 Reflection.Resolve(analysisProfile).default_perspective ??
72#pragma warning disable 618
75#pragma warning restore 618
80 string message = $
"Expected {first} and {second} to match";
82 Assert.IsTrue(first.
Equals(second), message);
83 Assert.IsTrue(second.
Equals(first), message);
84 Assert.AreEqual(first, second, message);
87 Console.WriteLine($
"Note: {first} and {second} are equivalent but their string representations are not.");
93 string message = $
"Expected {first} and {second} to differ";
94 Assert.IsFalse(first.
Equals(second), message);
95 Assert.IsFalse(second.
Equals(first), message);
96 Assert.AreNotEqual(first, second, message);
97 Assert.AreNotEqual(first.
ToString(), second.
ToString(), message +
", but their string representations do not.");
101 Assert.AreNotEqual(first.
GetHashCode(), second.
GetHashCode(), message +
", but their hash codes do not.");
103 #endregion Test Helper Methods
105 [TestMethod, TestCategory(Category)]
136 "NetLoss,Premium,ReinstatementBrokerage");
139 [TestMethod, TestCategory(Category)]
145 Perspective third =
"Premium,NetLoss,FixedExpense,ReinstatementBrokerage";
151 Perspective different =
"NetLoss,Premium,ReinstatementPremium,FixedExpense";
157 [TestMethod, TestCategory(Category)]
176 #region Legacy Perspective Tests
177 [TestMethod, TestCategory(Category)]
178 [Obsolete(
"Tests legacy perspective construction")]
193 "LossNetOfAggregateTerms[Premium,ReinstatementBrokerage]");
196 [TestMethod, TestCategory(Category)]
197 [Obsolete(
"Tests legacy perspective construction")]
203 _ =
new Perspective(
"ReinstatementBrokerage[Premium]");
204 _ =
new Perspective(
"LossNetOfAggregateTerms[BadOption]");
209 [TestMethod, TestCategory(Category)]
210 [Obsolete(
"Tests legacy perspective construction")]
219 Assert.IsTrue(perspective.
Equals(
"LossNetOfAggregateTerms"));
222 Assert.AreEqual(legacyConstruction, legacyConstruction.
ToString());
223 Assert.AreEqual(legacyConstruction,
"LossNetOfAggregateTerms");
232 [TestMethod, TestCategory(Category)]
233 [Obsolete(
"Tests legacy perspective construction")]
238 Perspective third =
"LossNetOfAggregateTerms[ReinstatementBrokerage,Premium]";
244 Perspective different =
"LossNetOfAggregateTerms[ReinstatementPremium,Premium]";
249 #endregion Legacy Perspective Tests
static Reflection Reflection
Shared instance of a class for generating random resources.
Test the Perspective Class.
void AssertEquivalence(Perspective first, Perspective second)
Assert that two perspectives constructed differently are treated as equivalent in every way.
static readonly Perspective.Base[] AllPerspectiveValues
A list of all perspective values.
void Test_Perspective_Legacy_OptionsForWrongBase()
void Test_Perspective_ConstructionTypes_Equal()
static IEnumerable< Perspective > LegacyTestPerspectives
Create a list of distinct perspectives to test.
static IEnumerable< Perspective > TestPerspectives
Create a list of distinct perspectives to test.
static readonly Perspective.Base[] NetPerspectiveModifiers
void Test_Perspective_Legacy_OptionsPermutations_Equal()
static Perspective GetDefaultPerspectiveForAnalysisProfile(IReference< AnalysisProfile > analysisProfile)
Get the AnalysisProfile.default_perspective of the analysis profile.
void AssertInequivalence(Perspective first, Perspective second)
Assert that two perspectives constructed differently are treated as equivalent in every way.
void Test_Perspective_Legacy_Equivalence()
void Test_Perspective_Legacy_ConstructionTypes_Equal()
void Test_Perspective_ToString()
void Test_Perspective_Permutations_Equal()
static readonly Perspective.Base[] CombinablePerspectiveValues
A list of all perspectives that can be combined with one-another.
The loss perspective determines what factors to include when computing a distribution.
static readonly Perspective ReinstatementBrokerage
Construct a distribution from the structure's net reinstatement brokerages.
static Perspective FromEnum(Base perspective)
Returns the appropriate singleton for the Base perspective given.
static readonly Perspective SlidingScaleCommission
Report on the structure's Fees.FixedExpense fees.
static readonly Perspective LossGross
Construct a distribution from the structure's gross losses.
static Perspective LossNetOf(params Base[] perspectives)
A convenience static method, similar to the other static singletons, which constructs a complex persp...
override string ToString()
Perspective string is just the class name.
static readonly Perspective ProportionalExpense
Report on the structure's Fees.ProportionalExpense fees.
bool Equals(Perspective other)
Determine whether the two perspectives are equivalent.
static readonly Perspective FixedExpense
Report on the structure's Fees.FixedExpense fees.
static readonly Perspective NetLoss
Construct a distribution from the structure's net losses.
override int GetHashCode()
Serves as a hash function for a particular type.
static readonly Perspective LossNetOfAggregateTerms
The legacy perspective value indicating "net loss" - but this includes fee record types as well.
static readonly Perspective NoClaimsBonus
Report on the structure's Fees.FixedExpense fees.
Base
The set of available values and RecordTypes that can be used to construct a distribution or metrics r...
static Perspective FromString(string perspectiveString)
Implicit converter that allows automatically converting a string into a perspective,...
static Perspective LossNetOfAggregateTermsAnd(bool premium=false, bool reinstatement_premium=false, bool reinstatement_brokerage=false)
Constructs a legacy LossNetOfAggregateTerms[X,Y,Z] perspective, where you can specify which values to...
static readonly Perspective Premium
Report on the structure's premium only.
static readonly Perspective ReinstatementPremium
Construct a distribution from the structure's net reinstatement premiums.
static readonly Perspective ProfitCommission
Report on the structure's Fees.FixedExpense fees.
static Perspective FromEnums(params Base[] perspectives)
Construct a new Perspective that should include the specified Base perspective value or values.
Helper class for extending the functionality of the static Enumclass with compile-time-type-specific ...
Base interface for all reference entities.