C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Test_LossSet.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using AnalyzeRe;
15
16#if MSTEST
17using Microsoft.VisualStudio.TestTools.UnitTesting;
18#elif NUNIT
19using NUnit.Framework;
20using TestClass = NUnit.Framework.TestFixtureAttribute;
21using TestMethod = NUnit.Framework.TestAttribute;
22using TestCategory = NUnit.Framework.CategoryAttribute;
23#endif
24
26{
27 [TestClass]
29 {
31
35 {
36 Console.WriteLine("Verifying that we can safely POST and simulate a LayerView " +
37 $"containing a reference to this {posted.GetType().NiceTypeName()}");
38 // Ensure the loss set processed successfully
40 posted = (T)asWithData.PollUntilReady();
41 // Post a new simple layer_view that includes this loss set
43 layerView.layer.loss_sets.Add(posted.ToReference());
44 layerView = layerView.Post();
45 // Assert that the layer_view can be simulated
46 TestSuite_APIResourceView.TestMetricsRetrievable(layerView);
47 }
48 }
49
50 #region ELTLossSet Derived Types Test Classes
51 [TestClass]
52 public sealed class TestSuite_LossSet_ELTLossSet : TestSuite_ELTLossSet<ELTLossSet>
53 {
54 #region Set Up and Configuration
55 private const string TypeName = "ELTLossSet";
58
59 protected override string POSTData => Samples.CSV.Loss_Set_1_Data;
60 #endregion Set Up and Configuration
61 }
62
63 [TestClass]
64 [Obsolete("This tests a now obsolete class for backwards compatibility purposes.")]
65 public sealed class TestSuite_LossSet_PortfolioLossSet : TestSuite_ELTLossSet<PortfolioLossSet>
66 {
67 #region Set Up and Configuration
68 private const string TypeName = "PortfolioLossSet";
71
72 protected override string POSTData => Samples.CSV.Loss_Set_1_Data;
73 #endregion Set Up and Configuration
74
75 #region POST
76 #region perspective
77 [TestMethod, TestCategory(TypeName)]
79 {
80 POST_WithValue(l => l.perspective, "ABC", false);
81 }
82 [TestMethod, TestCategory(TypeName)]
84 {
85 POST_WithValue(l => l.perspective, "A", false);
86 }
87 [TestMethod, TestCategory(TypeName)]
89 {
90 POST_Attribute_Null(l => l.perspective);
91 }
92 [TestMethod, TestCategory(TypeName)]
94 {
95 POST_StringAttribute_Empty(l => l.perspective);
96 }
97 #endregion perspective
98
99 #region analysis
100 [TestMethod, TestCategory(TypeName)]
102 {
103 POST_Attribute_Null(l => l.analysis);
104 }
105 [TestMethod, TestCategory(TypeName)]
107 {
108 POST_Reference_NullId(l => l.analysis);
109 }
110 [TestMethod, TestCategory(TypeName)]
115 [TestMethod, TestCategory(TypeName)]
120 #endregion analysis
121 #endregion POST
122
123 #region PUT
124 #region perspective
125 [TestMethod, TestCategory(TypeName)]
127 {
128 PUT_WithValue(l => l.perspective, "ZZ", true);
129 }
130 [TestMethod, TestCategory(TypeName)]
132 {
133 PUT_WithValue(l => l.perspective, "ABC", false);
134 }
135 [TestMethod, TestCategory(TypeName)]
137 {
138 PUT_WithValue(l => l.perspective, "A", false);
139 }
140 [TestMethod, TestCategory(TypeName)]
142 {
143 PUT_Attribute_Null(l => l.perspective);
144 }
145 [TestMethod, TestCategory(TypeName)]
147 {
148 PUT_StringAttribute_Empty(l => l.perspective);
149 }
150 #endregion perspective
151
152 #region analysis
153 [TestMethod, TestCategory(TypeName)]
155 {
156 PUT_WithValue(l => l.analysis,
158 }
159 [TestMethod, TestCategory(TypeName)]
161 {
162 PUT_Reference_NullId(l => l.analysis);
163 }
164 [TestMethod, TestCategory(TypeName)]
169 [TestMethod, TestCategory(TypeName)]
174 #endregion analysis
175 #endregion PUT
176 }
177
178 [TestClass]
179 [Obsolete("This tests a now obsolete class for backwards compatibility purposes.")]
180 public sealed class TestSuite_LossSet_TreatyLossSet : TestSuite_ELTLossSet<TreatyLossSet>
181 {
182 #region Set Up and Configuration
183 private const string TypeName = "TreatyLossSet";
186
187 protected override string POSTData => Samples.CSV.Loss_Set_2_Data;
188 #endregion Set Up and Configuration
189
190 #region POST
191 #region treaty
192 [TestMethod, TestCategory(TypeName)]
194 {
195 POST_Attribute_Null(l => l.treaty);
196 }
197 [TestMethod, TestCategory(TypeName)]
199 {
200 POST_WithValue(l => l.treaty, new TreatyLossSet.Treaty { id = null, description = null }, false);
201 }
202 #endregion treaty
203
204 #region analysis
205 [TestMethod, TestCategory(TypeName)]
207 {
208 POST_Attribute_Null(l => l.analysis);
209 }
210 [TestMethod, TestCategory(TypeName)]
212 {
213 POST_Reference_NullId(l => l.analysis);
214 }
215 [TestMethod, TestCategory(TypeName)]
220 [TestMethod, TestCategory(TypeName)]
225 #endregion analysis
226 #endregion POST
227
228 #region PUT
229 #region treaty
230 [TestMethod, TestCategory(TypeName)]
232 {
233 PUT_WithValue(l => l.treaty, new TreatyLossSet.Treaty { id = "2", description = "Test Treaty 2" }, true);
234 }
235 [TestMethod, TestCategory(TypeName)]
237 {
238 // If a treaty is supplied, all its values must be specified.
239 PUT_WithValue(l => l.treaty,
240 new TreatyLossSet.Treaty { id = null, description = null }, false);
241 }
242 [TestMethod, TestCategory(TypeName)]
244 {
245 PUT_Attribute_Null(l => l.treaty);
246 }
247 #endregion treaty
248
249 #region analysis
250 [TestMethod, TestCategory(TypeName)]
255 [TestMethod, TestCategory(TypeName)]
257 {
258 PUT_Reference_NullId(l => l.analysis);
259 }
260 [TestMethod, TestCategory(TypeName)]
265 [TestMethod, TestCategory(TypeName)]
270 #endregion analysis
271 #endregion PUT
272 }
273 #endregion ELTLossSet Derived Types Test Classes
274
275 #region LossSetWithData Derived Types Test Classes
276 [TestClass]
278 {
279 #region Set Up and Configuration
280 private const string TypeName = "YELTLossSet";
283
284 protected override string POSTData => Samples.CSV.YELTLossSet_10Trials;
285
288
289 protected override string POSTDataWithReinstatements =>
291 #endregion Set Up and Configuration
292
293 #region POST
294 #region event_catalogs
295 [TestMethod, TestCategory(TypeName)]
297 {
298 POST_Attribute_Null(l => l.event_catalogs);
299 }
300 [TestMethod, TestCategory(TypeName)]
302 {
303 POST_ListAttribute_Empty(l => l.event_catalogs);
304 }
305 [TestMethod, TestCategory(TypeName)]
307 {
308 POST_ReferenceList_NonExistantId(a => a.event_catalogs);
309 }
310 #endregion event_catalogs
311 #region yelt_adjustment_attributes
312 [TestMethod, TestCategory(TypeName)]
314 {
315 POST_WithValue(l => l.adjust_leap_years, true, true);
316 POST_WithValue(l => l.one_based_sequencing, true, true);
317 }
318 #endregion yelt_adjustment_properties
319
320 #region data_type
321 [TestMethod, TestCategory(TypeName)]
322 [Obsolete("ARE-5226 Remove support for Binary YELT Loss Set format. ")]
324 {
325 POST_WithValue(l => l.data_type, YELTLossSet.DataType.csv, true);
326 }
327
328 [TestMethod, TestCategory(TypeName)]
329 [Obsolete("ARE-5226 Remove support for Binary YELT Loss Set format. ")]
331 {
333 TestResource.Change(l => l.data_type, YELTLossSet.DataType.binary);
334 GenericTest.POST_WithData_ThenDoAction(binaryLossSet,
335 // We must also change the data we upload when we change the data type
337 TestSuite_LossSet_Base.Test_LossSet_Simulatable);
338 }
339 #endregion data_type
340 #endregion POST
341
342 #region PUT
343 #region event_catalogs
344 [TestMethod, TestCategory(TypeName)]
346 {
347 PUT_WithValue(l => l.event_catalogs,
348 new List<IReference<EventCatalog>> { Samples.EventCatalog.AsReference }, true);
349 }
350 [TestMethod, TestCategory(TypeName)]
352 {
353 PUT_Attribute_Null(l => l.event_catalogs);
354 }
355 [TestMethod, TestCategory(TypeName)]
357 {
358 PUT_ListAttribute_Empty(l => l.event_catalogs);
359 }
360 [TestMethod, TestCategory(TypeName)]
362 {
363 PUT_ReferenceList_NonExistantId(a => a.event_catalogs);
364 }
365 #endregion event_catalogs
366
367 #region data_type
368 [TestMethod, TestCategory(TypeName)]
369 [Obsolete("ARE-5226 Remove support for Binary YELT Loss Set format. ")]
371 {
372 PUT_WithValue(l => l.data_type, YELTLossSet.DataType.csv, true);
373 }
374
375 [TestMethod, TestCategory(TypeName)]
376 [Obsolete("ARE-5226 Remove support for Binary YELT Loss Set format. ")]
378 {
379 // We do not use the standard test, because we'll need to upload different data.
380 //PUT_WithValue(l => l.data_type, YELTLossSet.DataType.binary, true);
381 POST_ForPutTest(TestResource, posted =>
382 {
383 YELTLossSet toPut = posted.ShallowCopy().Change(l => l.data_type, YELTLossSet.DataType.binary);
385 // The server will initially accept the modifications
387 AssertApi.PutResponseMatches(posted, toPut, putResponse);
388 // Take advantage of this utility to add binary data.
389 putResponse = Reflection.FinalizePostedResource(putResponse);
390 AdditionalValidResourceTests(putResponse);
391 });
392 }
393 #endregion data_type
394 #endregion PUT
395 }
396
397 [TestClass]
399 {
400 #region Set Up and Configuration
401 private const string TypeName = "YLTLossSet";
404
405 protected override string POSTData => Samples.CSV.YLTLossSet_10Trials;
406 protected override LossType DefaultLossType => LossType.LossNetOfAggregateTerms;
407
410
411 protected override string POSTDataWithReinstatements =>
413 #endregion Set Up and Configuration
414
415 #region POST
416 #region attributes
417 [TestMethod, TestCategory(TypeName)]
419 {
420 POST_Attribute_Null(l => l.attributes);
421 }
422 [TestMethod, TestCategory(TypeName)]
424 {
425 POST_WithValue(l => l.attributes,
426 new Dictionary<string, string>(), true);
427 }
428 [TestMethod, TestCategory(TypeName)]
430 {
431 POST_WithValue(l => l.attributes,
433 { "Test1", "TestValue" },
434 { "Test2", "2" },
435 { "Test 3", "3.33" }
436 }, true);
437 }
438 #endregion attributes
439 #endregion POST
440
441 #region PUT
443 public override void Test_LossSet_PUT_LossType_Null()
444 {
445 // BUG: ARE-2618 - loss_type is left unchanged on PUT, but most other properties
446 // get "reset" to their default value on PUT - this is an inconsistency
447 // Note that this is only showing up for YLTLossSets because the default value
448 // is 'LossNetOfAggregateTerms', but the test resource has it set to 'LossGross'.
449 // Many other test resources have property values equal to their defaults, so
450 // the tests don't "detect" whether the property is being "reset" or left alone.
451 Skip.Indefinitely("ARE-2618 - Some Properties Not Reset on PUT");
452 base.Test_LossSet_PUT_LossType_Null();
453 }
454
455 #region attributes
456 [TestMethod, TestCategory(TypeName)]
458 {
459 PUT_WithValue(l => l.attributes,
460 new Dictionary<string, string>(), true);
461 }
462 [TestMethod, TestCategory(TypeName)]
464 {
465 PUT_WithValue(l => l.attributes,
467 { "Test1", "TestValue" },
468 { "Test2", "2" },
469 { "Test 3", "3.33" }
470 }, true);
471 }
472 #endregion attributes
473 #endregion PUT
474
475 #region data / profile tests
476 [TestMethod, TestCategory(TypeName)]
478 {
479 GenericTest.POST_ValidResourceWithData(new YLTLossSet
480 {
481 description = "Negative Losses",
482 currency = "USD",
483 trial_count = 10,
484 start_date = DateTime.Today
485 }, "trial_id,loss\n1,0\n2,-10");
486 }
487
488 [TestMethod, TestCategory(TypeName)]
490 {
491 GenericTest.POST_WithData_ThenDoAction(new YLTLossSet
492 {
493 description = "Simple YLT Profile",
494 currency = "USD",
495 trial_count = 10,
496 start_date = DateTime.Today
497 }, "trial_id,loss\n1,0\n2,10", ls =>
498 {
499 Assert.IsNotNull(ls.profile);
500 Assert.AreEqual(1.0, ls.profile.avg_annual_loss);
501 Assert.AreEqual(0d, ls.profile.min_loss);
502 Assert.AreEqual(10.0, ls.profile.max_loss);
503 Assert.AreEqual("USD", ls.profile.currency);
504 Assert.AreEqual(2, ls.profile.num_losses);
505 Assert.AreEqual(1, ls.profile.non_zero_losses);
506 });
507 }
508 #endregion data / profile tests
509 }
510 #endregion LossSetWithData Derived Types Test Classes
511
512 #region Other Loss Set Test Classes
513 [TestClass]
515 {
516 #region Set Up and Configuration
517 private const string TypeName = "ParametricLossSet";
518 protected override IInjectableResource<ParametricLossSet> TestInjectableResource =>
520 #endregion Set Up and Configuration
521
522 #region POST
523 #region attributes
524 [TestMethod, TestCategory(TypeName)]
526 {
527 POST_Attribute_Null(l => l.attributes);
528 }
529 [TestMethod, TestCategory(TypeName)]
531 {
532 POST_WithValue(l => l.attributes,
533 new Dictionary<string, string>(), true);
534 }
535 [TestMethod, TestCategory(TypeName)]
537 {
539 {
540 { "Test1", "TestValue" },
541 { "Test2", "2" },
542 { "Test 3", "3.33" }
543 }, true);
544 }
545 #endregion attributes
546
547 #region frequency
548 [TestMethod, TestCategory(TypeName)]
550 {
551 POST_Attribute_Null(a => a.frequency);
552 }
553 [TestMethod, TestCategory(TypeName)]
558 [TestMethod, TestCategory(TypeName)]
563 [TestMethod, TestCategory(TypeName)]
568 [TestMethod, TestCategory(TypeName)]
583 [TestMethod, TestCategory(TypeName)]
585 {
586 // Certain distribution types cannot be associated with this property, even though
587 // no type constraint is available to distinguish. Here we verify that the user
588 // returns an error for those loss set types that might mistakenly be used.
590 {
592 Samples.Distribution_CustomSeverityDistribution.AsReference
593 };
595 POST_WithValue(a => a.frequency, distribution, false);
596 }
597 #endregion frequency
598
599 #region seasonality
600 [TestMethod, TestCategory(TypeName)]
602 {
603 POST_Attribute_Null(a => a.seasonality);
604 }
605 [TestMethod, TestCategory(TypeName)]
610 [TestMethod, TestCategory(TypeName)]
615 [TestMethod, TestCategory(TypeName)]
620 [TestMethod, TestCategory(TypeName)]
635 [TestMethod, TestCategory(TypeName)]
637 {
638 // Certain distribution types cannot be associated with this property, even though
639 // no type constraint is available to distinguish. Here we verify that the user
640 // returns an error for those loss set types that might mistakenly be used.
642 {
644 Samples.Distribution_CustomSeverityDistribution.AsReference
645 };
647 POST_WithValue(a => a.seasonality, distribution, false);
648 }
649 #endregion seasonality
650
651 #region severity
652 [TestMethod, TestCategory(TypeName)]
654 {
655 POST_Attribute_Null(a => a.severity);
656 }
657 [TestMethod, TestCategory(TypeName)]
662 [TestMethod, TestCategory(TypeName)]
667 [TestMethod, TestCategory(TypeName)]
672 [TestMethod, TestCategory(TypeName)]
687 [TestMethod, TestCategory(TypeName)]
689 {
690 // Certain distribution types cannot be associated with this property, even though
691 // no type constraint is available to distinguish. Here we verify that the user
692 // returns an error for those loss set types that might mistakenly be used.
694 {
696 Samples.Distribution_CustomSeasonalityDistribution.AsReference
697 };
699 POST_WithValue(a => a.severity, distribution, false);
700 }
701 #endregion severity
702
703 #region start_date
704 [TestMethod, TestCategory(TypeName)]
706 {
708 POST_WithValue(l => l.start_date, minUtcDateTime, true);
709 }
710
711 [TestMethod, TestCategory(TypeName)]
713 {
714 DateTime maxUtcDateTime = new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc);
715 POST_WithValue(l => l.start_date, maxUtcDateTime, true);
716 }
717 #endregion start_date
718
719 #region profile
720 [TestMethod, TestCategory(TypeName)]
721 public override void Test_LossSet_CreatesProfile()
722 {
724 Assert.Inconclusive("RUN_OFFLINE = true");
725 // Overridden because the ParametricLossSet behaves slightly differently
726 ParametricLossSet ls = TestResource_Existing;
727 Assert.IsNotNull(ls.profile, "Profile was null");
728 Assert.IsNotNull(ls.profile.min_loss, "min_loss was null");
729 Assert.IsNotNull(ls.profile.max_loss, "max_loss was null");
730 Assert.IsNotNull(ls.profile.avg_annual_loss, "avg_annual_loss was null");
731 Assert.IsNotNull(ls.profile.num_losses, "num_losses was null");
732 // Only difference: No notion of non-zero losses for this loss set type.
733 // TODO: Can the server just set this==num_losses too (see ARE-3164)
734 Assert.IsNull(ls.profile.non_zero_losses, "non_zero_losses was null");
735 Assert.IsNotNull(ls.profile.currency, "Currency was null");
736 Assert.IsNotNull(ls.profile.attributes, "Attributes was null");
737 Assert.AreNotEqual(ls.profile.attributes.Count, 0, "Attributes were empty");
738 }
739 #endregion profile
740
741 #region event_id
742 [TestMethod, TestCategory(TypeName)]
744 {
745 POST_Attribute_Null(l => l.event_id);
746 }
747
748 [TestMethod, TestCategory(TypeName)]
750 {
751 POST_WithValue(l => l.event_id, 0uL, true);
752 }
753
754 [TestMethod, TestCategory(TypeName)]
756 {
757 // TODO: ARE-4300: The largest value currently allowed by the API is Int32.Max
758 // (even though the type is supposed to be an unsigned long and support up to UInt64.Max)
759 POST_WithValue(l => l.event_id, (ulong)Int32.MaxValue, true);
760 }
761
762 [TestMethod, TestCategory(TypeName)]
764 {
765 // TODO: ARE-4300: this should succeed once we fix all the API integer validation
766 POST_WithValue(l => l.event_id, UInt64.MaxValue, false);
767 }
768 #endregion event_id
769 #endregion POST
770
771 #region data / profile tests
772 [TestMethod, TestCategory(TypeName)]
774 {
775 GenericTest.POST_ThenDoAction(
776 new DiracDistribution { description = "1", value = 1 },
777 oneDist =>
778 {
779 POST_ThenDoAction(new ParametricLossSet
780 {
781 description = "Retro Coverage Income",
782 currency = "USD",
783 seasonality = oneDist.ToReference(),
784 severity = new DiracDistribution { description = "-1", value = -1 }.Post().ToReference(),
785 frequency = oneDist.ToReference(),
786 start_date = DateTime.Today
787 }, ls =>
788 {
789 Assert.IsNotNull(ls.profile);
790 Assert.AreEqual(-1d, ls.profile.avg_annual_loss);
791 Assert.AreEqual(-1d, ls.profile.min_loss);
792 Assert.AreEqual(-1d, ls.profile.max_loss);
793 Assert.AreEqual("USD", ls.profile.currency);
794 Assert.AreEqual(1, ls.profile.num_losses);
795 Assert.IsNull(ls.profile.non_zero_losses);
796 });
797 });
798 }
799 #endregion data / profile tests
800
801 [TestMethod, TestCategory(TypeName)]
803 {
804 // BUG ARE-6592 discovered that including a parametric loss set in a layer_view
805 // could cause its id to become non-deterministic.
806 //Skip.Indefinitely("ARE-6592: Posting a LayerView containing a ParametricLossSet...");
807 // TODO: Once this bug is fixed, we should start using parametric loss sets in
808 // our test resource more often.
810 testView.layer.loss_sets = Samples.AllLossSetTypesTestList
811 .Select(ls => ls.AsReference).ToList();
812 // In theory, this bug might exist for inlined filters as well
813 testView.layer.filters = new List<IReference<LossFilter>>
814 {
822 Samples.LossFilter_RecordTypeAnyOfFilter.AsReference
823 };
824
825 string expectedId = testView.Post().id;
826 // Re-post this layer_view several times. We expect to get the same id each time.
827 Enumerable.Range(1, 20).AsParallel().ForAll(i =>
828 GenericTest.POST_ThenDoAction(testView, posted =>
829 Assert.AreEqual(expectedId, posted.id,
830 $"The id of the posted layer_view changed on attempt {i} of 10, " +
831 $"despite the request being identical in each case.")));
832 }
833 }
834
835 [TestClass]
836 [Obsolete("This tests a now obsolete class for backwards compatibility purposes.")]
837 public sealed class TestSuite_LossSet_NestedLayerLossSet : TestSuite_LossSet<NestedLayerLossSet>
838 {
839 #region Set Up and Configuration
840 private const string TypeName = "NestedLayerLossSet";
841 protected override IInjectableResource<NestedLayerLossSet> TestInjectableResource =>
843 #endregion Set Up and Configuration
844
845 [TestMethod, TestCategory(TypeName)]
847 {
848 Skip.UntilRelease.Validation("ARE-6040: NestedLayerLossSet.loss_type " +
849 "should not be LossNetOfAggregateTerms, but API allows it.");
850 base.Test_LossSet_POST_LossType_LossNetOfAggregateTerms();
851 }
852
853 #region POST
854 #region layer
855 [TestMethod, TestCategory(TypeName)]
857 {
858 // Loop over each layer type, generated a nestedLayerLossSet with it, and test POST
860 GenericTest.POST_ValidResource(
862 }
863
864 [TestMethod, TestCategory(TypeName)]
866 {
867 // A layer may be posted such that it contains mixed loss set types. For a time
868 // this created issues with NestedLayerLossSets, but it should now be supported.
870 modified.loss_sets = Samples.AllLossSetTypesTestList.Select(ls => ls.AsReference).ToList();
872 InjectableResource.Create(modified)).Unposted);
873 }
874 #endregion layer
875
876 #region profile
877 [TestMethod, TestCategory(TypeName)]
878 public override void Test_LossSet_CreatesProfile()
879 {
881 Assert.Inconclusive("RUN_OFFLINE = true");
882 // In the case of NestedLayerLossSets, we expect the profile to be mostly empty
883 NestedLayerLossSet lossSet = TestResource_Existing;
884 Assert.IsNotNull(lossSet.profile, "Profile was null");
885 Assert.IsNull(lossSet.profile.min_loss, "Expected min_loss to be null");
886 Assert.IsNull(lossSet.profile.max_loss, "Expected max_loss to be null");
887 Assert.IsNull(lossSet.profile.avg_annual_loss, "Expected avg_annual_loss to be null");
888 Assert.IsNull(lossSet.profile.num_losses, "Expected num_losses to be null");
889 Assert.IsNotNull(lossSet.profile.currency, "Currency was null");
890 Assert.IsNotNull(lossSet.profile.attributes, "Attributes was null");
891 Assert.AreEqual(lossSet.profile.attributes.Count, 0, "Expected attributes to be empty");
892 }
893 #endregion profile
894 #endregion POST
895 }
896
897 [TestClass]
898 public sealed class TestSuite_LossSet_LoadedLossSet : TestSuite_LossSet<LoadedLossSet>
899 {
900 #region Set Up and Configuration
901 private const string TypeName = "LoadedLossSet";
902 protected override IInjectableResource<LoadedLossSet> TestInjectableResource =>
904 #endregion Set Up and Configuration
905
906 #region POST
907 #region source
908 [TestMethod, TestCategory(TypeName)]
910 {
911 // Loop over each LossSet type, generated a LoadedLossSe with it, and test POST
913 GenericTest.POST_ValidResource(Samples.GetInjectableLoadedLossSet(source, 1.5).Unposted);
914 }
915 #endregion source
916
917 #region load
918 [TestMethod, TestCategory(TypeName)]
920 {
921 POST_WithValue(l => l.load, Double.MaxValue, true);
922 }
923 [TestMethod, TestCategory(TypeName)]
925 {
926 POST_WithValue(l => l.load, Double.MinValue, true);
927 }
928 [TestMethod, TestCategory(TypeName)]
930 {
931 POST_WithValue(l => l.load, Double.NaN, false);
932 }
933 [TestMethod, TestCategory(TypeName)]
935 {
936 POST_WithValue(l => l.load, Double.PositiveInfinity, false);
937 }
938 [TestMethod, TestCategory(TypeName)]
940 {
941 POST_WithValue(l => l.load, Double.NegativeInfinity, false);
942 }
943 [TestMethod, TestCategory(TypeName)]
945 {
946 POST_WithValue(l => l.load, Math.PI / 1E12, true);
947 }
948 #endregion load
949 #endregion POST
950 }
951
952 [TestClass]
954 {
955 #region Set Up and Configuration
956 private const string TypeName = "QCLSLossSet";
957 protected override IInjectableResource<QCLSLossSet> TestInjectableResource =>
959 #endregion Set Up and Configuration
960
961 #region POST
962 #region correlation_coefficient
963 [TestMethod, TestCategory(TypeName)]
965 {
966 POST_WithValue(l => l.correlation_coefficient, 1d, true);
967 }
968 [TestMethod, TestCategory(TypeName)]
970 {
971 POST_WithValue(l => l.correlation_coefficient, -1d, true);
972 }
973 [TestMethod, TestCategory(TypeName)]
975 {
976 POST_WithValue(l => l.correlation_coefficient, 1.01d, false);
977 }
978 [TestMethod, TestCategory(TypeName)]
980 {
981 POST_WithValue(l => l.correlation_coefficient, -1.01d, false);
982 }
983 [TestMethod, TestCategory(TypeName)]
985 {
986 POST_WithValue(l => l.correlation_coefficient, Double.NaN, false);
987 }
988 [TestMethod, TestCategory(TypeName)]
990 {
991 POST_WithValue(l => l.correlation_coefficient, 0d, true);
992 }
993 [TestMethod, TestCategory(TypeName)]
995 {
996 POST_WithValue(l => l.correlation_coefficient, Math.PI / 1E12, true);
997 }
998 #endregion correlation_coefficient
999
1000 #region distribution
1001 [TestMethod, TestCategory(TypeName)]
1003 {
1004 POST_Attribute_Null(a => a.distribution);
1005 }
1006 [TestMethod, TestCategory(TypeName)]
1008 {
1009 POST_Reference_NullId(a => a.distribution);
1010 }
1011 [TestMethod, TestCategory(TypeName)]
1016 [TestMethod, TestCategory(TypeName)]
1021 [TestMethod, TestCategory(TypeName)]
1036 [TestMethod, TestCategory(TypeName)]
1038 {
1039 // Certain distribution types cannot be associated with this property, even though
1040 // no type constraint is available to distinguish. Here we verify that the user
1041 // returns an error for those loss set types that might mistakenly be used.
1043 {
1045 Samples.Distribution_CustomSeasonalityDistribution.AsReference
1046 };
1048 POST_WithValue(a => a.distribution, distribution, false);
1049 }
1050 #endregion distribution
1051
1052 #region simulation
1053 [TestMethod, TestCategory(TypeName)]
1055 {
1056 POST_Attribute_Null(a => a.simulation);
1057 }
1058 [TestMethod, TestCategory(TypeName)]
1060 {
1061 POST_Reference_NullId(a => a.simulation);
1062 }
1063 [TestMethod, TestCategory(TypeName)]
1068 [TestMethod, TestCategory(TypeName)]
1073 #endregion simulation
1074
1075 #region profile
1076 [TestMethod, TestCategory(TypeName)]
1077 public override void Test_LossSet_CreatesProfile()
1078 {
1079 // Currently, no loss set profile is created for this type.
1080 Skip.Indefinitely("ARE-3782: QCLS Loss Set Profile");
1081 base.Test_LossSet_CreatesProfile();
1082 }
1083 #endregion profile
1084 #endregion POST
1085 }
1086 #endregion Other Loss Set Test Classes
1087
1088 #region Abstract Base Test Classes
1090 [TestClass]
1093 {
1094 private const string TypeName = "ILossSet_Simulated";
1095
1096 #region Abstract Members
1097 protected abstract IInjectableResource<T> LossSetWithReinstatements { get; }
1098
1099 protected abstract string POSTDataWithReinstatements { get; }
1100 #endregion Abstract Members
1101
1102 #region POST
1103 #region trial_count
1104 [TestMethod, TestCategory(TypeName)]
1106 {
1107 POST_WithValue(s => s.trial_count, -1, false);
1108 }
1109 #endregion trial_count
1110
1111 #region start_date
1112 [TestMethod, TestCategory(TypeName)]
1114 {
1116 POST_WithValue(l => l.start_date, minUtcDateTime, true);
1117 }
1118
1119 [TestMethod, TestCategory(TypeName)]
1121 {
1122 DateTime maxUtcDateTime = new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc);
1123 POST_WithValue(l => l.start_date, maxUtcDateTime, true);
1124 }
1125 #endregion start_date
1126
1127 #region reinstatements_data_type
1128 [TestMethod, TestCategory(TypeName)]
1130 {
1131 POST_WithValue(l => l.reinstatements_data_type, ReinstatementsDataType.currency, true);
1132 }
1133
1134 [TestMethod, TestCategory(TypeName)]
1136 {
1137 POST_WithValue(l => l.reinstatements_data_type, ReinstatementsDataType.percentage, true);
1138 }
1139
1140 [TestMethod, TestCategory(TypeName)]
1142 {
1143 POST_Attribute_Null(l => l.reinstatements_data_type);
1144 }
1145 #endregion reinstatements_data_type
1146 #endregion POST
1147
1148 #region PUT
1149 #region trial_count
1150 [TestMethod, TestCategory(TypeName)]
1152 {
1153 PUT_WithValue(s => s.trial_count, 1234, true);
1154 }
1155 #endregion trial_count
1156
1157 #region start_date
1158 [TestMethod, TestCategory(TypeName)]
1160 {
1162 PUT_WithValue(l => l.start_date, minUtcDateTime, true);
1163 }
1164
1165 [TestMethod, TestCategory(TypeName)]
1167 {
1168 DateTime maxUtcDateTime = new DateTime(DateTime.MaxValue.Ticks, DateTimeKind.Utc);
1169 PUT_WithValue(l => l.start_date, maxUtcDateTime, true);
1170 }
1171 #endregion start_date
1172
1173 #region reinstatements_data_type
1174 [TestMethod, TestCategory(TypeName)]
1176 {
1177 PUT_WithValue(l => l.reinstatements_data_type, ReinstatementsDataType.currency, true);
1178 }
1179
1180 [TestMethod, TestCategory(TypeName)]
1182 {
1183 PUT_WithValue(l => l.reinstatements_data_type, ReinstatementsDataType.percentage, true);
1184 }
1185
1186 [TestMethod, TestCategory(TypeName)]
1188 {
1189 PUT_Attribute_Null(l => l.reinstatements_data_type);
1190 }
1191 #endregion reinstatements_data_type
1192 #endregion PUT
1193
1194 #region Reinstatement Information Tests
1197 [TestMethod, TestCategory(TypeName)]
1199 {
1200 GenericTest.POST_ValidResourceWithData(LossSetWithReinstatements.Unposted
1201 .Change(ls => ls.loss_type, LossType.LossNetOfAggregateTerms),
1202 POSTDataWithReinstatements);
1203 }
1204
1207 [TestMethod, TestCategory(TypeName)]
1209 {
1210 GenericTest.POST_InvalidResourceWithData_Fails(LossSetWithReinstatements.Unposted
1211 .Change(ls => ls.loss_type, LossType.LossGross), POSTDataWithReinstatements,
1212 // Expect an error on commit referencing the loss_type property.
1213 (CommitFailedException ex) => Assert.IsTrue(ex.Message.Contains(nameof(LossSet.loss_type))));
1214 }
1215
1216 #region Test Different Wrapper Layer Types
1217 private readonly MetricsOptions _requestPremium = MetricsOptions.Default
1218 .Change(o => o.perspective, Perspective.ReinstatementPremium);
1219
1222 private void Test_LossSet_ReinstatementInformation_Forwarded(ILayer_WithLossSets wrapperLayer)
1223 {
1225 Assert.Inconclusive("RUN_OFFLINE = true");
1226 T preparedResource = LossSetWithReinstatements.Posted;
1229 double rprem, new_rprem;
1230
1231 // Create a copy of the loss set with each reinstatements data type set.
1232 if (preparedResource.reinstatements_data_type == ReinstatementsDataType.currency)
1233 {
1236 .Change(ls => ls.reinstatements_data_type, ReinstatementsDataType.percentage)
1237 .Post().PollUntilReady(Samples.DataPollingOptions);
1238 }
1239 else
1240 {
1243 .Change(ls => ls.reinstatements_data_type, ReinstatementsDataType.currency)
1244 .Post().PollUntilReady(Samples.DataPollingOptions);
1245 }
1246
1247 // If this layer has a premium property, we will play with changing its value.
1248 // Even if this layer doesn't have a premium property, we should be able to test
1249 // that a loss set with 'currency' premium values has its values passed through.
1251 if (asWithPremium != null)
1252 asWithPremium.premium = new MonetaryUnit(5000, "USD");
1253
1254 PollingOptions simulationPolling = TestSuite_APIResourceView.SimulationPolling;
1255
1256 // A LayerView with fixed reinstatements should never change it's reinstatement premium
1257 wrapperLayer.loss_sets = new List<IReference<LossSet>> { fixed_reinstatements.ToReference() };
1258 testLayerView = Samples.GetInjectableLayerView(wrapperLayer).Posted;
1259 rprem = API.PollUntilReady(() => testLayerView.expected_loss(_requestPremium), simulationPolling);
1260 Assert.IsTrue(rprem > 0, "Expected some non-zero reinstatement premium.");
1261
1262 // Post a new layer with a different premium, assert that reinstatement premium is the same.
1263 if (asWithPremium != null)
1264 {
1265 asWithPremium.premium = new MonetaryUnit(0, "USD");
1266 testLayerView = Samples.GetInjectableLayerView(wrapperLayer).Posted;
1267 new_rprem = API.PollUntilReady(() => testLayerView.expected_loss(_requestPremium), simulationPolling);
1268 Assert.AreEqual(rprem, new_rprem, "Expected the reinstatement premium to remain the same.");
1269 }
1270
1271 // Now if we run the same experiment with loss type set to "percentage", we should see changes
1272 if (asWithPremium != null)
1273 asWithPremium.premium = new MonetaryUnit(5000, "USD");
1274 wrapperLayer.loss_sets = new List<IReference<LossSet>> { variable_reinstatements.ToReference() };
1275 testLayerView = Samples.GetInjectableLayerView(wrapperLayer).Posted;
1276 rprem = API.PollUntilReady(() => testLayerView.expected_loss(_requestPremium), simulationPolling);
1277 if (asWithPremium == null)
1278 {
1279 Assert.AreEqual(0, rprem, $"Expected the reinstatement premium to be zero " +
1280 $"since the wrapper layer type {wrapperLayer.GetType()} has no premium property.");
1281 return;
1282 }
1283 Assert.IsTrue(rprem > 0, "Expected some non-zero reinstatement premium.");
1284
1285 // Post a new layer with a premium of zero. Expect the reinstatement premium to become zero.
1286 asWithPremium.premium = new MonetaryUnit(0, "USD");
1287 testLayerView = Samples.GetInjectableLayerView(wrapperLayer).Posted;
1288 new_rprem = API.PollUntilReady(() => testLayerView.expected_loss(_requestPremium), simulationPolling);
1289 Assert.AreEqual(0, new_rprem, "Expected the reinstatement premium to be zero since premium is zero.");
1290 }
1291
1292 [TestMethod, TestCategory(TypeName)]
1294 {
1295 Test_LossSet_ReinstatementInformation_Forwarded(
1296 new QuotaShare { event_limit = new MonetaryUnit(Double.MaxValue, "USD") });
1297 }
1298
1299 [TestMethod, TestCategory(TypeName)]
1301 {
1302 Test_LossSet_ReinstatementInformation_Forwarded(new CatXL
1303 {
1304 attachment = new MonetaryUnit(0, "USD"),
1305 limit = new MonetaryUnit(Double.MaxValue, "USD"),
1306 franchise = new MonetaryUnit(0, "USD"),
1307 nth = 1,
1308 });
1309 }
1310
1311 [TestMethod, TestCategory(TypeName)]
1313 {
1314 Test_LossSet_ReinstatementInformation_Forwarded(new AggXL
1315 {
1316 attachment = new MonetaryUnit(0, "USD"),
1317 limit = new MonetaryUnit(Double.MaxValue, "USD"),
1318 aggregate_attachment = new MonetaryUnit(0, "USD"),
1319 aggregate_limit = new MonetaryUnit(Double.MaxValue, "USD"),
1320 franchise = new MonetaryUnit(0, "USD"),
1321 });
1322 }
1323
1324 [TestMethod, TestCategory(TypeName)]
1326 {
1327 Test_LossSet_ReinstatementInformation_Forwarded(new Generic
1328 {
1329 attachment = new MonetaryUnit(0, "USD"),
1330 limit = new MonetaryUnit(Double.MaxValue, "USD"),
1331 aggregate_attachment = new MonetaryUnit(0, "USD"),
1332 aggregate_limit = new MonetaryUnit(Double.MaxValue, "USD"),
1333 franchise = new MonetaryUnit(0, "USD"),
1334 });
1335 }
1336
1337 [TestMethod, TestCategory(TypeName)]
1339 {
1340 Test_LossSet_ReinstatementInformation_Forwarded(new Filter { invert = true });
1341 }
1342
1343 [TestMethod, TestCategory(TypeName)]
1345 {
1346 Test_LossSet_ReinstatementInformation_Forwarded(new FixedRateCurrencyConverter
1347 {
1348 in_currency = "USD",
1349 out_currency = "CAD",
1350 rate = 1.0
1351 });
1352 }
1353 #endregion Test Different Wrapper Layer Types
1354
1355 // TODO: Assert that the perspective "LossGross" cannot be queries on layers containing net loss sets.
1356 #endregion Reinstatement Information Tests
1357 }
1358
1362 [TestClass]
1364 {
1365 private const string TypeName = "ELTLossSet";
1366
1367 #region POST
1368 #region event_catalogs
1369 [TestMethod, TestCategory(TypeName)]
1371 {
1372 POST_Attribute_Null(l => l.event_catalogs);
1373 }
1374 [TestMethod, TestCategory(TypeName)]
1376 {
1377 POST_ListAttribute_Empty(l => l.event_catalogs);
1378 }
1379 [TestMethod, TestCategory(TypeName)]
1381 {
1382 POST_ReferenceList_NonExistantId(a => a.event_catalogs);
1383 }
1384 #endregion event_catalogs
1385 #endregion POST
1386
1387 #region PUT
1388 #region event_catalogs
1389 [TestMethod, TestCategory(TypeName)]
1391 {
1392 PUT_WithValue(l => l.event_catalogs, new List<IReference<EventCatalog>> { Samples.EventCatalog.AsReference }, true);
1393 }
1394 [TestMethod, TestCategory(TypeName)]
1396 {
1397 PUT_Attribute_Null(l => l.event_catalogs);
1398 }
1399 [TestMethod, TestCategory(TypeName)]
1401 {
1402 PUT_ListAttribute_Empty(l => l.event_catalogs);
1403 }
1404 [TestMethod, TestCategory(TypeName)]
1406 {
1407 PUT_ReferenceList_NonExistantId(a => a.event_catalogs);
1408 }
1409 #endregion event_catalogs
1410 #endregion PUT
1411 }
1412
1414 [TestClass]
1417 {
1418 private const string TypeName = "LossSetWithData";
1419 protected virtual LossType DefaultLossType => LossType.LossGross;
1420
1423 TestSuite_LossSet_Base.Test_LossSet_Simulatable(posted);
1424
1425 // We inherit some complex tests from BaseResourceWithLargeDataTest.
1426 // Ideally, we could also inherit the tests from Test_LossSet_WithCurrency<T>
1427 // (as well as the Test_LossSet<T> tests it inherits), but as multiple
1428 // inheritance is not supported, all we can do is copy those tests into
1429 // this alternate base test class.
1430 #region LossSet_WithCurrency
1431 // TODO: Ensure any new tests added to Test_LossSet_WithCurrency<T> are added below.
1432 #region POST
1433 #region currency
1434 [TestMethod, TestCategory(TypeName)]
1436 {
1437 POST_Attribute_Null(l => l.currency);
1438 }
1439 [TestMethod, TestCategory(TypeName)]
1441 {
1442 POST_StringAttribute_Empty(l => l.currency);
1443 }
1444 // TODO: Test enforce currency length = 3 characters
1445 #endregion currency
1446 #endregion POST
1447
1448 // PUT tests only apply to LossSets with Data since only these have a mutable state.
1449 #region PUT
1450 #region currency
1451 [TestMethod, TestCategory(TypeName)]
1453 {
1454 PUT_WithValue(l => l.currency, "CAD", true);
1455 }
1456 [TestMethod, TestCategory(TypeName)]
1458 {
1459 PUT_Attribute_Null(l => l.currency);
1460 }
1461 [TestMethod, TestCategory(TypeName)]
1463 {
1464 PUT_StringAttribute_Empty(l => l.currency);
1465 }
1466 #endregion currency
1467 #endregion PUT
1468 #endregion LossSet_WithCurrency
1469
1470 #region LossSet
1471 // TODO: Ensure any new tests added to Test_LossSet<T> are added below.
1472 #region POST
1473 #region loss_type
1474 [TestMethod, TestCategory(TypeName)]
1476 {
1477 POST_WithValue(l => l.loss_type, LossType.LossGross, true);
1478 }
1479 [TestMethod, TestCategory(TypeName)]
1481 {
1482 POST_WithValue(l => l.loss_type, LossType.LossNetOfAggregateTerms, true);
1483 }
1484 [TestMethod, TestCategory(TypeName)]
1486 {
1487 POST_Attribute_Null(ls => ls.loss_type);
1488 }
1489 #endregion loss_type
1490
1491 #region profile
1492 [TestMethod, TestCategory(TypeName)]
1493 public virtual void Test_LossSet_CreatesProfile()
1494 {
1496 Assert.Inconclusive("RUN_OFFLINE = true");
1497 T ls = TestResource_Existing;
1498 Assert.IsNotNull(ls.profile, "Profile was null");
1499 Assert.IsNotNull(ls.profile.min_loss, "min_loss was null");
1500 Assert.IsNotNull(ls.profile.max_loss, "max_loss was null");
1501 Assert.IsNotNull(ls.profile.avg_annual_loss, "avg_annual_loss was null");
1502 Assert.IsNotNull(ls.profile.num_losses, "num_losses was null");
1503 Assert.IsNotNull(ls.profile.non_zero_losses, "non_zero_losses was null");
1504 Assert.IsNotNull(ls.profile.currency, "Currency was null");
1505 Assert.IsNotNull(ls.profile.attributes, "Attributes was null");
1506 Assert.AreNotEqual(ls.profile.attributes.Count, 0, "Attributes were empty");
1507 }
1508 #endregion profile
1509 #endregion POST
1510
1511 // PUT tests only apply to LossSets with Data since only these have a mutable state.
1512 #region PUT
1513 #region loss_type
1514 [TestMethod, TestCategory(TypeName)]
1516 {
1517 PUT_WithValue(l => l.loss_type, LossType.LossGross, true);
1518 }
1519 [TestMethod, TestCategory(TypeName)]
1521 {
1522 PUT_WithValue(l => l.loss_type, LossType.LossNetOfAggregateTerms, true);
1523 }
1524 [TestMethod, TestCategory(TypeName)]
1526 {
1527 PUT_Attribute_Null(l => l.loss_type);
1528 }
1529 #endregion loss_type
1530 #endregion PUT
1531 #endregion LossSet
1532 }
1533
1534 [TestClass]
1536 {
1537 private const string TypeName = "LossSetWithLossType";
1538
1539 #region POST
1540 #region currency
1541 [TestMethod, TestCategory(TypeName)]
1543 {
1544 POST_Attribute_Null(l => l.currency);
1545 }
1546 [TestMethod, TestCategory(TypeName)]
1548 {
1549 POST_StringAttribute_Empty(l => l.currency);
1550 }
1551 // TODO: Test enforce currency length = 3 characters
1552 #endregion currency
1553 #endregion POST
1554 }
1555
1557 [TestClass]
1559 {
1560 private const string TypeName = "LossSet";
1561
1563 public override void AdditionalValidResourceTests(T posted) =>
1564 TestSuite_LossSet_Base.Test_LossSet_Simulatable(posted);
1565
1566 #region POST
1567 #region loss_type
1568 [TestMethod, TestCategory(TypeName)]
1570 {
1571 POST_WithValue(l => l.loss_type, LossType.LossGross, true);
1572 }
1573 [TestMethod, TestCategory(TypeName)]
1575 {
1576 POST_WithValue(l => l.loss_type, LossType.LossNetOfAggregateTerms, true);
1577 }
1578 [TestMethod, TestCategory(TypeName)]
1580 {
1581 POST_Attribute_Null(ls => ls.loss_type);
1582 }
1583 #endregion loss_type
1584
1585 #region profile
1586 [TestMethod, TestCategory(TypeName)]
1587 public virtual void Test_LossSet_CreatesProfile()
1588 {
1590 Assert.Inconclusive("RUN_OFFLINE = true");
1591 T ls = TestResource_Existing;
1592 Assert.IsNotNull(ls.profile, "Profile was null");
1593 Assert.IsNotNull(ls.profile.min_loss, "min_loss was null");
1594 Assert.IsNotNull(ls.profile.max_loss, "max_loss was null");
1595 Assert.IsNotNull(ls.profile.avg_annual_loss, "avg_annual_loss was null");
1596 Assert.IsNotNull(ls.profile.num_losses, "num_losses was null");
1597 Assert.IsNotNull(ls.profile.non_zero_losses, "non_zero_losses was null");
1598 Assert.IsNotNull(ls.profile.currency, "Currency was null");
1599 Assert.IsNotNull(ls.profile.attributes, "Attributes was null");
1600 Assert.AreNotEqual(ls.profile.attributes.Count, 0, "Attributes were empty");
1601 }
1602 #endregion profile
1603 #endregion POST
1604 }
1605 #endregion Abstract Base Test Classes
1606}
Tests for a stored resource collection which do not require an instance of that resource to be define...
A class containing a resource that can be Posted with dependencies.
Exposes the various sample CSV files as strings.
Definition Samples.CSV.cs:9
static string YELTLossSet_10Trials_ForBinary
static string YLTLossSet_WithReinstatements_10Trials
static string YELTLossSet_WithReinstatements_10Trials
static string YELTLossSet_10Trials
static string YLTLossSet_10Trials
Exposes sample resource objects, with built-in methods for injecting dependencies.
Definition Samples.cs:14
IInjectableResource< NegativeBinomialDistribution > Distribution_NegativeBinomialDistribution
IInjectableResource< CustomSeasonalityDistribution > Distribution_CustomSeasonalityDistribution
static readonly PollingOptions DataPollingOptions
Polling options to use when uploading a data file.
IInjectableResource< RangeFilter > LossFilter_RangeFilter
IInjectableResource< YELTLossSet > LossSet_YELTLossSet
IInjectableResource< PoissonDistribution > Distribution_PoissonDistribution
IInjectableResource< ELTLossSet > LossSet_ELTLossSet
IInjectableResource< NormalDistribution > Distribution_NormalDistribution
IInjectableResource< AggXL > Layer_AggXL
IInjectableResource< ILayerView< QuotaShare > > LayerView_QuotaShare
List< IInjectableResource< ILayer > > AllSaveableLayerTypesTestList
A list of one of each type of layer that can be POSTed. Layer types that cannot be posted on their ow...
IInjectableResource< OrFilter > LossFilter_OrFilter
IInjectableResource< LogNormalDistribution > Distribution_LogNormalDistribution
IInjectableResource< CustomSeverityDistribution > Distribution_CustomSeverityDistribution
IInjectableResource< NestedLayerLossSet > LossSet_NestedLayerLossSet
A simple NestedLayerLossSet retaining a CatXL layer's losses.
IInjectableResource< ILayerView< Filter > > LayerView_Filter
IInjectableResource< LoadedLossSet > LossSet_LoadedLossSet
A simple LoadedLossSet loading a ELTLossSets losses.
IInjectableResource< QCLSLossSet > LossSet_QCLSLossSet
IInjectableResource< VendorTreatyAnalysis > Analysis_VendorTreatyAnalysis
IInjectableResource< YELTLossSet > LossSet_YELTLossSetWithReinstatements
IInjectableResource< NestedLayerLossSet > GetInjectableNestedLayerLossSet(IInjectableResource< ILayer > layer, LossType? loss_type=null)
Factory for producing injectable NestedLayerLossSets using a POSTable injectable Layer for use in tes...
IInjectableResource< TreatyLossSet > LossSet_TreatyLossSet
IInjectableResource< ParametricLossSet > LossSet_ParametricLossSet
IInjectableResource< ParetoDistribution > Distribution_ParetoDistribution
IInjectableResource< AndFilter > LossFilter_AndFilter
IInjectableResource< VendorPortfolioAnalysis > Analysis_VendorPortfolioAnalysis
IInjectableResource< DiracDistribution > Distribution_DiracDistribution
IInjectableResource< BinomialDistribution > Distribution_BinomialDistribution
List< IInjectableResource< LossSet > > AllLossSetTypesTestList
One sample of each loss set type, all with the loss_type set to LossType.LossGross to maximize potent...
IInjectableResource< LTFilter > LossFilter_LTFilter
IInjectableResource< YLTLossSet > LossSet_YLTLossSet
IInjectableResource< LoadedLossSet > GetInjectableLoadedLossSet(IInjectableResource< LossSet > source, double load=1.0, LossType? loss_type=null)
Factory for producing injectable LoadedLossSets using a POSTable injectable Layer for use in testing.
IInjectableResource< AnyFilter > LossFilter_AnyFilter
IInjectableResource< YLTLossSet > LossSet_YLTLossSetWithReinstatements
IInjectableResource< GTFilter > LossFilter_GTFilter
IInjectableResource< AnyOfFilter > LossFilter_AnyOfFilter
IInjectableResource< CustomFrequencyDistribution > Distribution_CustomFrequencyDistribution
IInjectableResource< PortfolioLossSet > LossSet_PortfolioLossSet
Contains static helper methods for testing IAPIResourceView instances.
Includes tests that affect all types of ELTLossSet. Because these have a data endpoint,...
static void Test_LossSet_Simulatable< T >(T posted)
Asserts that a loss set can be included in a layer_view and simulated without any issue.
override IResourceCollection< LossSet > collection_source
override IInjectableResource< ELTLossSet > TestInjectableResource
override IInjectableResource< PortfolioLossSet > TestInjectableResource
Includes tests shared by both YLTLossSets and YELTLossSets.
void Test_LossSet_POST_LossNetOfAggregateTerms_ReinstatementInformation()
Assert that the system allows reinstatement information to exist in the file if the loss type is Loss...
void Test_LossSet_POST_LossGross_ReinstatementInformation()
Assert that the system does not allow reinstatement information to exist in the file if the loss type...
override IInjectableResource< TreatyLossSet > TestInjectableResource
Includes tests that affect all LossSets that require data upload.
override IInjectableResource< YELTLossSet > TestInjectableResource
override IInjectableResource< YELTLossSet > LossSetWithReinstatements
override IInjectableResource< YLTLossSet > TestInjectableResource
override IInjectableResource< YLTLossSet > LossSetWithReinstatements
Includes tests that affect all types of LossSet.
override void AdditionalValidResourceTests(T posted)
Deriving classes can optionally override this function to perform additional validation on every succ...
static void MethodIsAllowed(Action request, string methodName, bool methodAllowed=true)
Wrap a request in a tryGet with some formatting for testing purposes.
Definition AssertApi.cs:98
Retrieve settings from environment variables if they exist, or the project settings file otherwise.
static bool RUN_OFFLINE
Controls whether tests that normally require a connection to the server should be allowed to try to r...
Generic Unit test implementations that will test REST methods on arbitrary resources.
static void ExecuteWithConsoleErrorLogging(Action action, Func< string > additionalContext=null)
Wraps the call to the action with a try/catch that doesn't handle the exception, just logs some usefu...
A collection of filthy hacks to populate some fields of APIResources objects of any type.
Definition Reflection.cs:41
A helper class containing default skip dates.
Definition SkipUntil.cs:66
static void Validation(string ticket=null)
Skip a test due to a validation-related issue, possibly with no insight into when this issue is likel...
Class used in unit tests to mark tests as skipped by using Assert.Inconclusive() method.
Definition SkipUntil.cs:14
static void Indefinitely(string ticket=null)
Skip the specified test.
Definition SkipUntil.cs:54
Describes a collection of resources which can be listed.
API methods / requests made available to the user.
static readonly ResourceCollection< LossSet > LossSets
The collection of LossSets on the server.
Describes a distribution that always returns the same value. This distribution can be used as either ...
Exception raised when the commit process fails.
Representation of an Aggregate Catastrophe Excess of Loss layer.
Definition AggXL.cs:8
Representation of a Catastrophe Excess of Loss (CatXL) layer.
Definition CatXL.cs:9
Filter is like a layer whose 'terms' are to filter events out of the loss sources....
Definition Filter.cs:13
A structure that can be used to change the currency of a loss stream from one currency to another at ...
Representation of an Aggregate Catastrophe Excess of Loss layer with reinstatements.
Definition Generic.cs:10
Representation of a Quota Share contract.
Definition QuotaShare.cs:9
Base class for all LossSet sub-types. A LossSet is a resource that generates sample (trial) losses wh...
Definition LossSet.cs:13
LossType? loss_type
Indicates what types of losses are generated by this loss set. If not specified the server will defau...
Definition LossSet.cs:53
Representation of a single loss set with an associated event loss table.
Definition ELTLossSet.cs:10
Base for all conventional loss sets, which generate losses, have a server-generated loss profile,...
Base for all loss sets for which pre-generated loss data must be uploaded.
Representation of a Nested layer loss set, which represents any loss set whose losses are derived fro...
Representation of a Parametric loss set.
Custom TreatyLossSet treaty reference type.
Representation of a TreatyLossSet.
Representation of a loss set with an associated year-event-loss table.
DataType
The format of the data uploaded against this YELT.
Representation of a loss set with an associated simulated yearly losses table.
Definition YLTLossSet.cs:11
Optional parameters which can be specified for all metrics requests.
Representation of a monetary value with a currency.
The loss perspective determines what factors to include when computing a distribution.
static readonly Perspective ReinstatementPremium
Construct a distribution from the structure's net reinstatement premiums.
Determines the behaviour of the API when automatically retrying a request whose result is not yet rea...
IReference< T > AsReference
A reference to the posted resource.
T Unposted
The unPOSTed resource definition.
Abstract representation of a layer with terms.
Abstract representation of a layer with terms.
An interface for pre-simulated loss sets some data associated with them, some hard-coded seasonality ...
Combines the interfaces for a loss set and a resource with a data endpoint.
LossType
Indicates what types of losses are generated by this loss set.
Definition LossType.cs:5
ReinstatementsDataType
Dictates how any reinstatement information associated with a loss set should be interpreted.
@ currency
Reinstatement values represent a fixed dollar amount.