Пример #1
0
        public void TestSetNameSubsystemWorks()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name      = "mysendable";
            const string subsystem = "subsystem";

            registry.Add(sendableMock.Object, subsystem, name);

            Assert.True(registry.Contains(sendableMock.Object));

            var storedName = registry.GetName(sendableMock.Object);

            Assert.Equal(name, storedName);

            var storedSubsystem = registry.GetSubsystem(sendableMock.Object);

            Assert.NotNull(storedSubsystem);

            Assert.Equal(subsystem, storedSubsystem);

            const string newName      = "1234";
            const string newSubsystem = "abc";

            registry.SetName(sendableMock.Object, newSubsystem, newName);

            Assert.Equal($"{newName}", registry.GetName(sendableMock.Object));

            Assert.Equal(newSubsystem, registry.GetSubsystem(sendableMock.Object));
        }
Пример #2
0
        public void TestSetNameModuleNumberWorks()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name         = "mysendable";
            const int    channel      = 42;
            const int    moduleNumber = 8;

            registry.Add(sendableMock.Object, name, moduleNumber, channel);

            Assert.True(registry.Contains(sendableMock.Object));

            var storedName = registry.GetName(sendableMock.Object);

            Assert.Equal($"{name} [{moduleNumber},{channel}]", storedName);

            const string newName        = "1234";
            const int    newChannel     = 18;
            const int    newModuleNumer = 56;

            registry.SetName(sendableMock.Object, newName, newModuleNumer, newChannel);

            Assert.Equal($"{newName} [{newModuleNumer},{newChannel}]", registry.GetName(sendableMock.Object));
        }
Пример #3
0
        public void TestSetDataNegativeIndex()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            registry.Add(sendableMock.Object, "mysendable");

            string data = "42";

            Assert.Throws <ArgumentOutOfRangeException>(() => registry.SetData(sendableMock.Object, -1, data));
        }
Пример #4
0
        public void TestSetDataOnceWorks()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            registry.Add(sendableMock.Object, "mysendable");

            string data = "42";

            Assert.Null(registry.SetData(sendableMock.Object, 0, data));
            Assert.Equal(data, registry.GetData(sendableMock.Object, 0));
        }
Пример #5
0
        public void TestAddWithChannelAddsCorrectly()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name    = "mysendable";
            const int    channel = 42;

            registry.Add(sendableMock.Object, name, channel);

            Assert.True(registry.Contains(sendableMock.Object));

            var storedName = registry.GetName(sendableMock.Object);

            Assert.Equal($"{name} [{channel}]", storedName);
        }
Пример #6
0
        public void TestRemovesCorrectly()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name = "mysendable";

            registry.Add(sendableMock.Object, name);

            Assert.True(registry.Contains(sendableMock.Object));

            Assert.True(registry.Remove(sendableMock.Object));

            Assert.False(registry.Contains(sendableMock.Object));

            Assert.Empty(registry.GetName(sendableMock.Object));
        }
Пример #7
0
        public void TestAddAddsCorrectly()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name = "mysendable";

            registry.Add(sendableMock.Object, name);

            Assert.True(registry.Contains(sendableMock.Object));

            var storedName = registry.GetName(sendableMock.Object);

            Assert.NotNull(storedName);

            Assert.Equal(name, storedName);
        }
Пример #8
0
        public void TestSetSubsystem()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name = "mysendable";

            registry.Add(sendableMock.Object, name);

            Assert.True(registry.Contains(sendableMock.Object));

            Assert.Equal("Ungrouped", registry.GetSubsystem(sendableMock.Object));

            const string subsystem = "subsystem";

            registry.SetSubsystem(sendableMock.Object, subsystem);

            Assert.Equal(subsystem, registry.GetSubsystem(sendableMock.Object));
        }