为什么SignalR没有发送我的所有数据?

时间:2016-07-25 19:38:16

标签: c# signalr signalr-hub signalr.client

我正在尝试将数据发送到客户端

 this.serviceCommandHub.Clients.Client(this.Command.ConnectionId)
     .CommandCompleted(this.Command);

这是一个单元测试,我在单元测试中自我托管集线器。 该命令充满了数据,它继承自接口和基类。基类使用System.Runtime.Serialization.DataContractAttribute进行修饰 这是我的客户代码:

serviceCommandHub.On<MockTransfereeCommand>("CommandCompleted", c =>
    {
        var cmd = c as MockTransfereeCommand;
        Assert.AreEqual(transfereeCommand.ConnectionId, cmd.ConnectionId);
        Assert.AreEqual(transfereeCommand.Id, c.Id);
        manualResetEventCommandCompleted.Set();
    });

我收到了正确的“Createdby”,“CreatedDt”和一个字符串字段,其中包含正确的常量。所有这些都是基类和接口的属性,以及字符串,但它们不是唯一具有所有这些共同点的属性。

任何人都可以告诉我为什么我错过了传回的数据吗?

这是我的基础对象:

public abstract class CommandBase
{
    protected CommandBase();
    protected CommandBase(string commandAction, string grsSystem, string createdBy, DateTime? createdDate);

    [System.Runtime.Serialization.DataMemberAttribute]
    [Required]
    public string CommandAction { get; set; }
    public string ConnectionId { get; set; }
    [System.Runtime.Serialization.DataMemberAttribute]
    public DateTime CreateDate { get; set; }
    [System.Runtime.Serialization.DataMemberAttribute]
    [Required]
    public string CreatedBy { get; set; }
    [System.Runtime.Serialization.DataMemberAttribute]
    [Required]
    public string GrsSystem { get; set; }
    public int? Id { get; set; }
    public string UniqueKey { get; set; }

    public static class Actions
    {
        public const string Add = "Add";
        public const string Delete = "Delete";
        public const string Update = "Update";
    }
}

这是我的界面

    public interface ICommand
{
    string CommandAction { get; set; }
    string ConnectionId { get; set; }
    DateTime CreateDate { get; set; }
    string CreatedBy { get; set; }
    string GrsSystem { get; set; }
    //
    // Summary:
    //     Gets or sets the Id of Command, created when the command is issued, and returned
    //     to the caller to allow the caller to query for the command
    int? Id { get; set; }
    //
    // Summary:
    //     Gets or sets the UniqueKey for the command. Commands that are issued with Unique
    //     keys that have already been used, will be rejected. Client should generate a
    //     GUID or other unique key and add it to the command.
    string UniqueKey { get; set; }
}

这是我的命令

    public class MockTransfereeCommand : CommandBase, ICommand
{
    public string CommandType { get; set; }

    public GrsSystemType GrsSystemType { get; set; }

    internal Transferee Transferee { get; set; }
}

0 个答案:

没有答案