コード例 #1
0
            public void WhenContainerNotActive_Throws()
            {
                Container.Stop(false);
                Action action = () => Container.ReservePort(3000);

                Assert.Throws <InvalidOperationException>(action);
            }
コード例 #2
0
            public void ReturnsReservedPort()
            {
                TcpPortManager.ReserveLocalPort(3000, _containerUsername).Returns(5000);

                var port = Container.ReservePort(3000);

                Assert.Equal(5000, port);
            }
コード例 #3
0
            public void ReleasesPorts()
            {
                TcpPortManager.ReserveLocalPort(Arg.Any <int>(), Arg.Any <string>())
                .Returns(c => c.Arg <int>());

                Container.ReservePort(100);
                Container.ReservePort(101);

                Container.Destroy();

                TcpPortManager.Received(1).ReleaseLocalPort(100, User.UserName);
                TcpPortManager.Received(1).ReleaseLocalPort(101, User.UserName);
            }
コード例 #4
0
            public void ReturnsListOfReservedPorts()
            {
                TcpPortManager.ReserveLocalPort(1000, Arg.Any <string>()).Returns(1000);
                TcpPortManager.ReserveLocalPort(1001, Arg.Any <string>()).Returns(1001);

                Container.ReservePort(1000);
                Container.ReservePort(1001);

                var info = Container.GetInfo();

                Assert.Collection(info.ReservedPorts,
                                  x => Assert.Equal(1000, x),
                                  x => Assert.Equal(1001, x)
                                  );
            }
コード例 #5
0
            public void ReservesPortForContainerUser()
            {
                Container.ReservePort(3000);

                TcpPortManager.Received(1).ReserveLocalPort(3000, _containerUsername);
            }