Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        public void TestSetNameNonExistantDoesNothing()
        {
            var registry = new SendableRegistry();

            var sendableMock = new Mock <ISendable>();

            const string name = "mysendable";

            registry.SetName(sendableMock.Object, name);

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

            Assert.Equal(string.Empty, storedName);
        }
Ejemplo n.º 4
0
        public void TestSetNameStockWorks()
        {
            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);

            const string newName = "1234";

            registry.SetName(sendableMock.Object, newName);

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