public ThingChannel(IThingChannelHandler thingChannelHandler, ThingId thingId, IMessageHub messageHub) { _thingChannelHandler = thingChannelHandler; _messageHub = messageHub; Id = new ThingChannelId(thingId, Name); _state = new SynchronizedValue <ThingState>(); }
public void Parse_InvalidIdString_ThrowsException() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; Assert.Throws <FormatException>(() => ThingChannelId.Parse($"{driver}:{gateway}:{thing}:{channel}:1")); }
public void Equals_NullId_ReturnsFalse() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.False(thingChannelId.Equals((IdBase)null)); }
public void GetHashCode_ThingChannelId_EqualsIdStringHashCode() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.Equal(thingChannelId.ToString().GetHashCode(), thingChannelId.GetHashCode()); }
public void Equals_SameId_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.True(thingChannelId.Equals(thingChannelId)); }
public void TryParse_InvalidIdString_ReturnsFalseAndThingChannelIdNull() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var parseOk = ThingChannelId.TryParse($"{driver}:{gateway}:{thing}:{channel}:1", out var thingChannelId); Assert.False(parseOk); Assert.Null(thingChannelId); }
public void Equals_NotSameIdString_ReturnsFalse() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; const string driver2 = "Driver2"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.False(thingChannelId.Equals($"{driver2}:{gateway}:{thing}:{channel}")); }
public void Equals_SameIdStringObject_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); object id = $"{driver}:{gateway}:{thing}:{channel}"; Assert.True(thingChannelId.Equals(id)); }
public void Parse_ValidIdString_ReturnsThingChannelId() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = ThingChannelId.Parse($"{driver}:{gateway}:{thing}:{channel}"); Assert.Equal(driver, thingChannelId.Driver); Assert.Equal(gateway, thingChannelId.Gateway); Assert.Equal(thing, thingChannelId.Thing); Assert.Equal(channel, thingChannelId.Channel); }
public void Equals_OtherIdWithSameValueObject_ReturnsTrue() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); var thingChannelId2 = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); object id = thingChannelId2; Assert.True(thingChannelId.Equals(id)); }
public void TryParse_ValidIdString_ReturnsTrueAndOutThingChannelId() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; var parseOk = ThingChannelId.TryParse($"{driver}:{gateway}:{thing}:{channel}", out var thingChannelId); Assert.True(parseOk); Assert.Equal(driver, thingChannelId.Driver); Assert.Equal(gateway, thingChannelId.Gateway); Assert.Equal(thing, thingChannelId.Thing); Assert.Equal(channel, thingChannelId.Channel); }
public void Driver_CreateId_GetValueOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; const string driver2 = "Driver2"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.Equal(driver, thingChannelId.Driver); thingChannelId.Driver = driver2; Assert.Equal(driver2, thingChannelId.Driver); }
public void Channel_CreateId_GetValueOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; const string channel2 = "Channel2"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.Equal(thing, thingChannelId.Thing); thingChannelId.Channel = channel2; Assert.Equal(channel2, thingChannelId.Channel); }
public void ToString_CreateId_ResultOk() { const string driver = "Driver1"; const string gateway = "Gateway1"; const string thing = "Thing1"; const string channel = "Channel1"; const string driver2 = "Driver2"; const string gateway2 = "Gateway2"; const string thing2 = "Thing2"; const string channel2 = "Channel2"; var thingChannelId = new ThingChannelId(new ThingId(new GatewayId(driver, gateway), thing), channel); Assert.Equal($"{driver}:{gateway}:{thing}:{channel}", thingChannelId.ToString()); thingChannelId.Driver = driver2; thingChannelId.Gateway = gateway2; thingChannelId.Thing = thing2; thingChannelId.Channel = channel2; Assert.Equal($"{driver2}:{gateway2}:{thing2}:{channel2}", thingChannelId.ToString()); }
protected ThingChannelHandlerBase(ThingId thingId, string name) { Name = name; ChannelId = new ThingChannelId(thingId, name); }