2using System.Collections.Generic;
10using Microsoft.VisualStudio.TestTools.UnitTesting;
13using TestClass = NUnit.Framework.TestFixtureAttribute;
14using TestMethod = NUnit.Framework.TestAttribute;
15using TestCategory = NUnit.Framework.CategoryAttribute;
23 private const string TestCategory =
"Serializers";
27 [TestMethod, TestCategory(TestCategory)]
34 description =
"Sample Cascaded Layer",
44 [TestMethod, TestCategory(TestCategory)]
51 description =
"Sample Cascaded Layer",
60 [TestMethod, TestCategory(TestCategory)]
65 modified.meta_data =
new Dictionary<string, object>
89 AssertApi.PostResponseMatches(modified, result);
95 [TestMethod, TestCategory(TestCategory)]
101 string json = weakReference.Serialize();
103 AssertApi.AllPropertiesEqual(weakReference, restored);
108 json = nested.Serialize();
110 AssertApi.AllPropertiesEqual(nested, restored2);
114 json = weakReference.Serialize();
116 AssertApi.AllPropertiesEqual(weakReference, restored);
121 [TestMethod, TestCategory(TestCategory)]
128 string serializedResult = catXLView.Serialize(pretty:
true);
129 Console.WriteLine(
"Serialized (default):\n" + serializedResult);
134 AssertApi.AllPropertiesEqual(catXLView, deserialized);
137 Assert.AreEqual(catXLView.
id, deserialized.
id);
142 serializedResult = catXLView.Serialize(
true,
false);
143 Console.WriteLine(
"\nSerialized (exclude server-generated):\n" + serializedResult);
145 Assert.IsNull(deserialized.
id);
146 Assert.IsNull(deserialized.
ylt_id);
147 Assert.IsNull(deserialized.
layer.
id);
Create a test class that takes care of setting the server URL and cleaning up after each unit test.
A class containing a resource that can be Posted with dependencies.
T Posted
The posted resource, ready to be referenced.
Exposes sample resource objects, with built-in methods for injecting dependencies.
IInjectableResource< Generic > Layer_Generic
static string Valid_NonExistant_UUID
IInjectableResource< CatXL > Layer_CatXL
IInjectableResource< ILayerView< CatXL > > LayerView_CatXL
void Test_API_POST_NestedLayer_Referenced()
Test that the serializer produces a valid Cascaded Loss Set containing a reference to a layer when th...
void Test_Serialize_Extension()
Test that the serialize extension method returns all properties of the resource, including server-gen...
void Test_API_Serialize_WeaklyTypedReference()
Serializers and comparers are sensitive to dealing with weakly typed generic types,...
void Test_API_POST_NestedLayer_Nested()
Test that the serializer produces a valid Cascaded Loss Set containing a fully resolved layer when th...
void Test_API_POST_Metadata_Nested_Dictionary_and_List()
Test that deserializing a layer whose metadata contains a nested dictionary correctly returns a dicti...
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.
A pre-configured RestSharp serializer / deserializer which is made to support parsing of AnalyzeRe AP...
static readonly AnalyzeReJsonConverter Default
Returns the default AnalyzeReJsonConverter instance.
object Deserialize(string json, Type deserializeType)
Deserializes the rest response to a run-time type as per this converter's configuration.
Represents the Analysis of a Layer.
Representation of a Catastrophe Excess of Loss (CatXL) layer.
A wrapper for a List<T> of IReference<ILayerSource> references that simplifies the construction and u...
void Add(IReference reference, bool automaticTyping=true)
Allows a weakly-typed reference to be added to this collection, with the possibility of runtime check...
Allows one or more source layers or layer_views to be attached as loss sources to some other layer de...
Sources sources
A list of the source layers forwarding losses to this layer.
Interface for a class containing a resource that can be Posted with dependencies.
IReference< T > AsInlinedReference
A reference to the unPOSTed resource (i.e. an inlined reference).
IReference< T > AsReference
A reference to the posted resource.
T Unposted
The unPOSTed resource definition.
T Posted
The posted resource, ready to be referenced.
string ylt_id
The hash identifier for the simulation results of this layer.
string id
The resource's unique identifier. It will be used in the request URL when requesting the resource fro...
Represents the Analysis of a Layer.
ILayer layer
The layer contained in this LayerView.