public void GeoCodeWithValueAndValueNameIsValid() { var area = new Area(); string value = "0123"; string valueName = "HSAS"; var geoCode = new GeoCode(valueName, value); area.GeoCodes.Add(geoCode); var geoCodesValidator = new GeoCodesValidator(area); Assert.True(geoCodesValidator.IsValid); }
public void GeoCodeWithNullValueIsInvalid() { var area = new Area(); string value = null; string valueName = "HSAS"; var geoCode = new GeoCode(valueName, value); area.GeoCodes.Add(geoCode); var geoCodesValidator = new GeoCodesValidator(area); Assert.False(geoCodesValidator.IsValid); //Assert.Equal(typeof(GeoCodeError), geoCodesValidator.Errors.ElementAt(0).GetType()); }
private static Alert CreateMultipleAlertXmlAlert() { var orangeAlert = new Alert { //<?xml version = "1.0" encoding = "UTF-8"?> //<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"> // <identifier>43b080713727</identifier> Identifier = "43b080713727", // <sender>[email protected]</sender> Sender = "*****@*****.**", // <sent>2003-04-02T14:39:01-05:00</sent> Sent = new DateTimeOffset(2003, 4, 2, 14, 39, 1, TimeSpan.FromHours(-5)), // <status>Actual</status> Status = Status.Actual, // <msgType>Alert</msgType> MessageType = MessageType.Alert, // <scope>Public</scope> Scope = Scope.Public, // <source>source</source> Source = "source", // <restriction>restriction</restriction> Restriction = "restriction", // <code>code</code> Code = "code", // <note>note</note> Note = "note", // <references>references</references> }; //<references>references reference2</references> orangeAlert.References.Add("references"); orangeAlert.References.Add("reference2"); //<addresses>"address 1" address2 " address 3" address4</addresses> orangeAlert.Addresses.Add("address 1"); orangeAlert.Addresses.Add("address2"); orangeAlert.Addresses.Add(" address 3"); orangeAlert.Addresses.Add("address4"); //<incidents>" incident0" incident1 incident2 "bad incident" "another bad incident"</incidents> orangeAlert.Incidents.Add(" incident0"); orangeAlert.Incidents.Add("incident1"); orangeAlert.Incidents.Add("incident2"); orangeAlert.Incidents.Add("bad incident"); orangeAlert.Incidents.Add("another bad incident"); // <info> var info = new Info(); // <language>en-US</language> info.Language = "en-US"; // <category>Security</category> info.Categories.Add(Category.Security); // <event>Homeland Security Advisory System Update</event> info.Event = "Homeland Security Advisory System Update"; // <responsetype>Shelter</responsetype> info.ResponseTypes.Add(ResponseType.Shelter); // <urgency>Immediate</urgency> info.Urgency = Urgency.Immediate; // <severity>Severe</severity> info.Severity = Severity.Severe; // <certainty>Likely</certainty> info.Certainty = Certainty.Likely; // <audience>audience</audience> info.Audience = "audience"; //<eventcode> // <valuename>valN</valuename> // <value>val</value> //</eventcode> info.EventCodes.Add(new EventCode("valN", "val")); info.EventCodes.Add(new EventCode("valN1", "val1")); // <effective>2003-04-02T14:39:01-05:00</effective> info.Effective = new DateTimeOffset(2003, 4, 2, 14, 39, 1, TimeSpan.FromHours(-5)); // <onset>2003-04-02T14:39:01-05:00</onset> info.Onset = new DateTimeOffset(2003, 4, 2, 14, 39, 1, TimeSpan.FromHours(-5)); // <expires>2003-04-02T14:39:01-05:00</expires> info.Expires = new DateTimeOffset(2003, 4, 2, 14, 39, 1, TimeSpan.FromHours(-5)); // <senderName>U.S. Government, Department of Homeland Security</senderName> info.SenderName = "U.S. Government, Department of Homeland Security"; // <headline>Homeland Security Sets Code ORANGE</headline> info.Headline = "Homeland Security Sets Code ORANGE"; // <description>The Department of Homeland Security has elevated the Homeland Security Advisory System threat level to ORANGE / High in response to intelligence which may indicate a heightened threat of terrorism.</description> info.Description = "The Department of Homeland Security has elevated the Homeland Security Advisory System threat level to ORANGE / High in response to intelligence which may indicate a heightened threat of terrorism."; // <instruction>A High Condition is declared when there is a high risk of terrorist attacks. In addition to the Protective Measures taken in the previous Threat Conditions, Federal departments and agencies should consider agency-specific Protective Measures in accordance with their existing plans.</instruction> info.Instruction = "A High Condition is declared when there is a high risk of terrorist attacks. In addition to the Protective Measures taken in the previous Threat Conditions, Federal departments and agencies should consider agency-specific Protective Measures in accordance with their existing plans."; // <web>http://www.dhs.gov/dhspublic/display?theme=29</web> info.Web = new Uri("http://www.dhs.gov/dhspublic/display?theme=29"); // <contact>contact</contact> info.Contact = "contact"; // <parameter> // <valueName>HSAS</valueName> // <value>ORANGE</value> // </parameter> info.Parameters.Add(new Parameter("HSAS", "ORANGE")); // <resource> info.Resources.Add(new Resource { // <resourceDesc>Image file (GIF)</resourceDesc> Description = "Image file (GIF)", // <mimeType>image/gif</mimeType> MimeType = "image/gif", // <size>1</size> Size = 1, // <uri>http://www.dhs.gov/dhspublic/getAdvisoryImage</uri> Uri = new Uri("http://www.dhs.gov/dhspublic/getAdvisoryImage"), // <derefUri>ZGVyZWZVcmk=</derefUri> DereferencedUri = Convert.FromBase64String("ZGVyZWZVcmk="), // <digest>digest</digest> Digest = "digest", // </resource> }); // <area> var area = new Area { // <areaDesc>U.S. nationwide and interests worldwide</areaDesc> Description = "U.S. nationwide and interests worldwide", // <altitude>altitude</altitude> Altitude = 100, // <ceiling>ceiling</ceiling> Ceiling = 120, }; //<polygon>1 2 3 4</polygon> //<polygon>1 22 33 4</polygon> area.Polygons.Add(new Polygon("1,2 2,2 3,3 4,4")); area.Polygons.Add(new Polygon("1,1 22,1 33,1 1,1")); //<circle>1 2</circle> //<circle>1 22</circle> area.Circles.Add(new Circle(new Coordinate(1, 2), 2)); area.Circles.Add(new Circle(new Coordinate(1, 2), 22)); //<geocode> // <valueName>valN</valueName> // <value>val</value> //</geocode> //<geocode> // <valueName>valN1</valueName> // <value>val1</value> //</geocode> area.GeoCodes.Add(new GeoCode("valN", "val")); area.GeoCodes.Add(new GeoCode("valN1", "val1")); info.Areas.Add(area); // </area> // </info> orangeAlert.Info.Add(info); //</alert> return orangeAlert; }