/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetActiveTestResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Test if (entry.Key == "Test") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Test = new TestDetails((IDictionary <string, object>)entry.Value); } } // Test Group else if (entry.Key == "TestGroup") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); TestGroup = new TestGroupDetails((IDictionary <string, object>)entry.Value); } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public AssignedTest(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("StartDate"), "Json is missing required field 'StartDate'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TestGroup"), "Json is missing required field 'TestGroup'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Name if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Key else if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Start Date else if (entry.Key == "StartDate") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); StartDate = JsonSerialisation.DeserialiseDate((string)entry.Value); } // End Date else if (entry.Key == "EndDate") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); EndDate = JsonSerialisation.DeserialiseDate((string)entry.Value); } } // Custom Data else if (entry.Key == "CustomData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); CustomData = new MultiTypeValue((object)entry.Value); } } // Test Group else if (entry.Key == "TestGroup") { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); TestGroup = new TestGroupDetails((IDictionary <string, object>)entry.Value); } } }
/// <summary> /// Initialises a new instance with the given required properties. /// </summary> /// /// <param name="name">The name of the Test.</param> /// <param name="key">The key of the Test.</param> /// <param name="startDate">The Date the Test began. Format: ISO8601 e.g. 2016-01-12T11:08:23.</param> /// <param name="testGroup">Details of the Test Group.</param> public AssignedTestDesc(string name, string key, DateTime startDate, TestGroupDetails testGroup) { ReleaseAssert.IsNotNull(name, "Name cannot be null."); ReleaseAssert.IsNotNull(key, "Key cannot be null."); ReleaseAssert.IsNotNull(startDate, "Start Date cannot be null."); ReleaseAssert.IsNotNull(testGroup, "Test Group cannot be null."); Name = name; Key = key; StartDate = startDate; TestGroup = testGroup; }
/// <summary> /// Initialises a new instance with the given description. /// </summary> /// /// <param name="desc">The description.</param> public AssignedTest(AssignedTestDesc desc) { ReleaseAssert.IsNotNull(desc, "A description object cannot be null."); ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null."); ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null."); ReleaseAssert.IsNotNull(desc.StartDate, "StartDate cannot be null."); ReleaseAssert.IsNotNull(desc.TestGroup, "TestGroup cannot be null."); Name = desc.Name; Key = desc.Key; StartDate = desc.StartDate; EndDate = desc.EndDate; CustomData = desc.CustomData; TestGroup = desc.TestGroup; }