public void ToMessageWithNonMatchingDataType() { var translator = new EndpointInteractionInformationConverter(); var data = new SuccessData { Id = new MessageId(), InResponseTo = new MessageId(), Sender = new EndpointId("a"), }; var msg = translator.ToMessage(data); Assert.IsInstanceOf(typeof(UnknownMessageTypeMessage), msg); Assert.AreSame(data.Id, msg.Id); Assert.AreSame(data.Sender, msg.Sender); Assert.AreSame(data.InResponseTo, msg.InResponseTo); }
public void ToMessage() { var translator = new EndpointInteractionInformationConverter(); var data = new EndpointInteractionInformationData { Id = new MessageId(), InResponseTo = new MessageId(), Sender = new EndpointId("a"), Groups = new[] { new SerializedSubjectInformation { Subject = "a", Commands = new[] { new SerializedTypeFallback { Types = new[] { new SerializedVersionedType { Type = new SerializedType { FullName = typeof(int).FullName, AssemblyName = typeof(int).Assembly.GetName().Name, }, Version = new Version(1, 0) }, } }, }, Notifications = new[] { new SerializedTypeFallback { Types = new[] { new SerializedVersionedType { Type = new SerializedType { FullName = typeof(double).FullName, AssemblyName = typeof(double).Assembly.GetName().Name, }, Version = new Version(1, 0) }, } }, }, }, } }; var msg = translator.ToMessage(data); Assert.IsInstanceOf(typeof(EndpointInteractionInformationMessage), msg); Assert.AreSame(data.Id, msg.Id); Assert.AreSame(data.Sender, msg.Sender); Assert.AreEqual(data.Groups.Length, ((EndpointInteractionInformationMessage)msg).SubjectGroups.Length); Assert.AreEqual(new CommunicationSubject(data.Groups[0].Subject), ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Subject); Assert.AreEqual(data.Groups[0].Commands.Length, ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Commands.Length); Assert.IsTrue( ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Commands[0].IsPartialMatch( new VersionedTypeFallback( new Tuple <OfflineTypeInformation, Version>( new OfflineTypeInformation( typeof(int).FullName, typeof(int).Assembly.GetName()), new Version(1, 0))))); Assert.IsFalse( ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Commands[0].IsPartialMatch( new VersionedTypeFallback( new Tuple <OfflineTypeInformation, Version>( new OfflineTypeInformation( typeof(double).FullName, typeof(double).Assembly.GetName()), new Version(1, 0))))); Assert.AreEqual(data.Groups[0].Notifications.Length, ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Notifications.Length); Assert.IsFalse( ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Notifications[0].IsPartialMatch( new VersionedTypeFallback( new Tuple <OfflineTypeInformation, Version>( new OfflineTypeInformation( typeof(int).FullName, typeof(int).Assembly.GetName()), new Version(1, 0))))); Assert.IsTrue( ((EndpointInteractionInformationMessage)msg).SubjectGroups[0].Notifications[0].IsPartialMatch( new VersionedTypeFallback( new Tuple <OfflineTypeInformation, Version>( new OfflineTypeInformation( typeof(double).FullName, typeof(double).Assembly.GetName()), new Version(1, 0))))); }