コード例 #1
0
        public void Parse_LegacyInput_ReturnsData()
        {
            // Arrange
            var target   = new DataAvailableNotificationParser();
            var contract = new DataAvailableNotificationContract
            {
                UUID             = "94681547-C70D-409C-9255-83B310AF7010",
                MessageType      = "messageType",
                Origin           = "TimeSeries",
                Recipient        = "recipient",
                RelativeWeight   = 5,
                SupportsBundling = true
            };

            // Act
            var actual = target.Parse(contract.ToByteArray());

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(contract.UUID, actual.Uuid.ToString().ToUpper(CultureInfo.InvariantCulture));
            Assert.Equal(contract.MessageType, actual.MessageType.Value);
            Assert.Equal(contract.Origin, actual.Origin.ToString());

#pragma warning disable CS0618
            var legacyVariant = (LegacyActorIdDto)actual.Recipient;
#pragma warning restore CS0618

            Assert.Equal(contract.Recipient, legacyVariant.LegacyValue);
            Assert.Equal(contract.RelativeWeight, actual.RelativeWeight);
            Assert.Equal(contract.SupportsBundling, actual.SupportsBundling);
        }
コード例 #2
0
        public void Parse_ValidInput_ReturnsData()
        {
            // Arrange
            var target   = new DataAvailableNotificationParser();
            var contract = new DataAvailableNotificationContract
            {
                UUID             = "94681547-C70D-409C-9255-83B310AF7010",
                Recipient        = "F3FD4E86-BF06-456A-9CC5-6D38FB471DE3",
                MessageType      = "messageType",
                Origin           = "TimeSeries",
                RelativeWeight   = 5,
                SupportsBundling = true
            };

            // Act
            var actual = target.Parse(contract.ToByteArray());

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(contract.UUID, actual.Uuid.ToString().ToUpper(CultureInfo.InvariantCulture));
            Assert.Equal(contract.MessageType, actual.MessageType.Value);
            Assert.Equal(contract.Origin, actual.Origin.ToString());
            Assert.Equal(Guid.Parse(contract.Recipient), actual.Recipient.Value);
            Assert.Equal(contract.RelativeWeight, actual.RelativeWeight);
            Assert.Equal(contract.SupportsBundling, actual.SupportsBundling);
        }
コード例 #3
0
        public void Parse_InvalidInput_ThrowsException()
        {
            // Arrange
            var target = new DataAvailableNotificationParser();

            // Act + Assert
            Assert.Throws <MessageHubException>(() => target.Parse(new byte[] { 1, 2, 3 }));
        }
コード例 #4
0
        public void Parse_InvalidGuid_ThrowsException()
        {
            // Arrange
            var target   = new DataAvailableNotificationParser();
            var contract = new DataAvailableNotificationContract
            {
                UUID             = "invalid_guid",
                MessageType      = "messageType",
                Origin           = "TimeSeries",
                Recipient        = "recipient",
                RelativeWeight   = 5,
                SupportsBundling = true
            };

            // Act + Assert
            Assert.Throws <MessageHubException>(() => target.Parse(contract.ToByteArray()));
        }