Beispiel #1
0
        public void Given_TheServerIsListening_When_JoinMulticastGroupIsCalled_Then_ItJoinsAMulticastGroup()
        {
            IPAddress joinedAddress = null;
            EndPoint  endPoint      = new IPEndPoint(IPAddress.Parse("::1"), 1234);

            var udpWrapper = Mock.Of <IUdpWrapper>(x =>
                                                   x.HostEndPoint == endPoint
                                                   );

            var returnedAddress = new IPAddress(new byte[] { 192, 168, 0, 1 });

            var addressProvider = Mock.Of <ISacnMulticastAddressProvider>(x =>
                                                                          x.GetMulticastAddress(It.IsAny <UInt16>()) == returnedAddress
                                                                          );

            Mock.Get(udpWrapper)
            .Setup(x => x.JoinMulticastGroup(It.IsAny <IPAddress>()))
            .Callback <IPAddress>(addr => joinedAddress = addr);

            var server = new TestMulticastSacnReceiver(udpWrapper, addressProvider);

            server.Listen(IPAddress.Any);
            server.JoinMulticastGroup(1);

            Assert.Equal(returnedAddress, joinedAddress);
        }
Beispiel #2
0
        public void Given_TheUniverseIsTooLow_When_TheUniverseIsSet_Then_AnExceptionIsThrown()
        {
            var udpWrapper = Mock.Of <IUdpWrapper>();
            var server     = new TestMulticastSacnReceiver(udpWrapper, Mock.Of <ISacnMulticastAddressProvider>());

            server.Listen(IPAddress.Any);
            Assert.Throws <ArgumentOutOfRangeException>(() => server.JoinMulticastGroup(Constants.Universe_MinValue - 1));
        }