Ejemplo n.º 1
0
        public ThingChannel(IThingChannelHandler thingChannelHandler, ThingId thingId, IMessageHub messageHub)
        {
            _thingChannelHandler = thingChannelHandler;
            _messageHub          = messageHub;

            Id     = new ThingChannelId(thingId, Name);
            _state = new SynchronizedValue <ThingState>();
        }
Ejemplo n.º 2
0
        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"));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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}"));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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));
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
 protected ThingChannelHandlerBase(ThingId thingId, string name)
 {
     Name      = name;
     ChannelId = new ThingChannelId(thingId, name);
 }