public void ConvertToAlarmTest()
        {
            // Arrange
            var guid = Guid.NewGuid();
            var itemState = new DateTime(2012, 3, 31, 1, 15, 30);
            var alarmState = new DateTime(2012, 1, 31, 3, 15, 30);
            var localTime = TimeZoneInfo.Local;

            var rpcalarm = new AlarmMessage
            {
                MessageBase = new MessageBase
                {
                    PartitionName = "Partition Name",
                    IsPublic = "0",
                    Category = "TestCategory",
                    Priority = "5",
                    SiteName = "JCI",
                    Escalation = "4",
                    TimestampUtc = new DateTimeOffset(alarmState, localTime.GetUtcOffset(alarmState)).ToString(CultureInfo.InvariantCulture),
                },
                MessageDecode = new MessageDecode(),
                MessageDetails = new AlarmMessageDetails
                {
                    AlarmGuid = guid.ToString(),
                    Description = "Item Name",
                    ConditionTimestampUtc = new DateTimeOffset(itemState, localTime.GetUtcOffset(itemState)).ToString(CultureInfo.InvariantCulture),
                    AlarmType = "3", // "Area"
                    AlarmTypeName = "Area",
                    ResponseRequired = "1",
                    AcknowledgeRequired = "1",
                    AlarmState = "4", // "Pending"
                    AlarmStateName = "Pending",
                    ConditionSequenceNumber = "1",
                    ConditionState = "1", // Alarm
                    ConditionStateName = "Alarm",
                    InstructionText = "Instructions or Alarm",
                    CanComplete = "0",
                    CanRespond = "1"
                    
                }
            };

            var expected = new Alarm(
                guid,
                "Item Name",
                Guid.Empty,
                "Partition Name",
                false,
                new DateTimeOffset(itemState, localTime.GetUtcOffset(itemState)),  //since my pc is set to central, after the conversion to local, 1/31 will be -5 (DST), not offset (-7)
                "Area",
                "TestCategory",
                5,
                true,
                true,
                4,
                "Pending",
                new DateTimeOffset(alarmState, localTime.GetUtcOffset(alarmState)),     //since my pc is set to central, after the conversion to local, 1/31 will be -6, not offset (-7)
                1,
                             "JCI",
                             1,
                             "Alarm",
                             4,
                             "Instructions or Alarm",
                             "No",
                             true,
                             false,
                             true,
                             false,
                             false
                );  // has everything including enumerations converted to our domain objects

            //Act
            var actual = rpcalarm.ConvertToAlarm(TimeZoneInfo.Local, CultureInfo.CurrentCulture);

            //Assert
            DtoAssert.AreEqual(expected, actual);      //test against expected object
        }
        private static IEnumerable<AlarmMessage> CreateAlarmMessages()
        {
            var alarms = new List<AlarmMessage>();
            var date = new DateTime(2012, 3, 31, 1, 15, 30);

            for (int i = 0; i < 3; i++)
            {
                var rpcalarm = new AlarmMessage
                {
                    MessageBase = new MessageBase
                    {
                        BaseVersion = "301",
                        MessageType = "3",
                        MessageSubtype = "2",
                        SiteName = "MKESite",
                        PartitionName = "Partition Name" + i,
                        IsPublic = "0",
                        ItemName = "Item Name" + i,
                        QueryString = "",
                        Category = "P2000",
                        Escalation = "0",
                        Priority = "0",
                        OperatorName = "cardkey",
                        HistoryFilterKey = "2",
                        HistoryFilterName = "Alarm",
                        TimestampUtc = date.ToString(CultureInfo.InvariantCulture)
                    },
                    MessageDecode = new MessageDecode
                    {
                        MessageDateTime = "6/13/2012 3:31:06 PM",
                        MessageTypeText = "Alarm",
                        MessageText = "Acked, Set",
                        DetailsText = "Details" + i
                    },
                    MessageDetails = new AlarmMessageDetails
                    {
                        MessageVersion = "301",
                        AlarmGuid = Guid.NewGuid().ToString(),
                        AlarmId = "10",
                        AlarmType = "2",
                        AlarmOptionsGuid = Guid.NewGuid().ToString(),
                        AlarmTypeName = "Input Point",
                        AlarmTypeId = "21",
                        AcknowledgeRequired = "0",
                        ResponseRequired = "0",
                        InstructionText = "",
                        AlarmState = (i == 0 ? 3 : 4).ToString(CultureInfo.InvariantCulture), //4 is pending,
                        AlarmStateName = "Acked",
                        AlarmTimestamp = date.ToString(CultureInfo.InvariantCulture),
                        ConditionState = "1",
                        ConditionStateName = "Set",
                        ConditionSequenceNumber = i.ToString(CultureInfo.InvariantCulture),
                        ConditionCompletionState = "0",
                        ConditionCompletionStateName = "Secure",
                        ConditionTimestamp = date.ToString(CultureInfo.InvariantCulture),
                        ConditionTimestampUtc = date.ToString(CultureInfo.InvariantCulture),
                        Popup = "1",
                        Description = "Description" + i,
                        AlarmSiteName = "MKESite",
                        AlarmResponseText = "",
                        CanAcknowledge = "0",
                        CanRespond = "1",
                        CanComplete = "0",
                    }
                };

                alarms.Add(rpcalarm);
            }
            return alarms;
        }
 public AlarmMessageReceivedEventArgs(AlarmMessage alarmMessage)
 {
     AlarmMessage = alarmMessage;
 }
 private static AlarmGetListExReply GetAlarmGetListExReply(AlarmMessage[] messages =null, SortOrder sortOrder =null)
 {
     return new AlarmGetListExReply
                {
                    AlarmMessages = messages??new AlarmMessage[0],
                    SortOrder = sortOrder?? new SortOrder(new[] {new Services.SortKey()})
                };
 }