public void ToMessage() { var serializers = new Mock <IStoreObjectSerializers>(); { serializers.Setup(s => s.HasSerializerFor(It.IsAny <Type>())) .Callback <Type>(t => Assert.IsTrue(typeof(int).Equals(t))) .Returns(true); serializers.Setup(s => s.SerializerFor(It.IsAny <Type>())) .Returns(new NonTransformingObjectSerializer()); } var translator = new NotificationRaisedConverter(serializers.Object); var id = NotificationId.Create(typeof(InteractionExtensionsTest.IMockNotificationSetWithTypedEventHandler).GetEvent("OnMyEvent")); var data = new NotificationRaisedData { Id = new MessageId(), InResponseTo = new MessageId(), Sender = new EndpointId("a"), NotificationId = NotificationIdExtensions.Serialize(id), EventArgumentsType = new SerializedType { FullName = typeof(int).FullName, AssemblyName = typeof(int).Assembly.GetName().Name, }, EventArguments = new EventArgs(), }; var msg = translator.ToMessage(data); Assert.IsInstanceOf(typeof(NotificationRaisedMessage), msg); Assert.AreSame(data.Id, msg.Id); Assert.AreSame(data.Sender, msg.Sender); Assert.AreEqual(id, ((NotificationRaisedMessage)msg).Notification.Notification); Assert.AreSame(data.EventArguments, ((NotificationRaisedMessage)msg).Notification.EventArgs); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationRaisedMessage"/> class. /// </summary> /// <param name="origin">The endpoint that send the original message.</param> /// <param name="id">The ID of the current message.</param> /// <param name="eventNotification">The information about the <see cref="INotificationSet"/> notification that was raised.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="origin"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="id"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="eventNotification"/> is <see langword="null" />. /// </exception> public NotificationRaisedMessage(EndpointId origin, MessageId id, NotificationRaisedData eventNotification) : base(origin, id) { { Lokad.Enforce.Argument(() => eventNotification); } Notification = eventNotification; }
public void Create() { var id = new EndpointId("sendingEndpoint"); var notification = NotificationId.Create( typeof(InteractionExtensionsTest.IMockNotificationSetWithTypedEventHandler).GetEvent("OnMyEvent")); var args = new MockEventArgs(1); var notificationRaised = new NotificationRaisedData(notification, args); var msg = new NotificationRaisedMessage(id, notificationRaised); Assert.AreSame(id, msg.Sender); Assert.AreSame(notification, msg.Notification.Notification); Assert.AreSame(args, msg.Notification.EventArgs); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationRaisedMessage"/> class. /// </summary> /// <param name="origin">The endpoint that send the original message.</param> /// <param name="eventNotification">The information about the <see cref="INotificationSet"/> notification that was raised.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="origin"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="eventNotification"/> is <see langword="null" />. /// </exception> public NotificationRaisedMessage(EndpointId origin, NotificationRaisedData eventNotification) : this(origin, new MessageId(), eventNotification) { }