public void ConnectControlSingleton_ToggleConnection_SelectedServerIndexIsOutofRange_StudioRepositoryLoadIsNotCalled()
        {
            var serverProvider        = new Mock <IEnvironmentModelProvider>();
            var environmentRepository = new Mock <IServerRepository>();
            var environmentModels     = new List <IServer>
            {
                new TestServer(new Mock <IEventAggregator>().Object, Guid.NewGuid(), CommonSetupHelper.CreateConnection(false).Object, new Mock <IResourceRepository>().Object, false)
            };

            serverProvider.Setup(s => s.Load()).Returns(environmentModels);
            IConnectControlSingleton connectControlSingleton = new ConnectControlSingleton(serverProvider.Object, environmentRepository.Object);
            var eventWasRaised = false;

            connectControlSingleton.ConnectedStatusChanged += (sender, arg) =>
            {
                eventWasRaised = true;
            };
            //------------Execute Test---------------------------
            connectControlSingleton.ToggleConnection(99);
            connectControlSingleton.ToggleConnection(-1);
            //------------Assert Results-------------------------
            Assert.IsNotNull(connectControlSingleton);

            Assert.IsFalse(eventWasRaised);
        }
        public void ConnectControlSingleton_ToggleConnection_SelectedServerIsDisconnected_StudioRepositoryLoadIsCalled()
        {
            var serverProvider        = new Mock <IEnvironmentModelProvider>();
            var environmentRepository = new Mock <IServerRepository>();
            var environmentModels     = new List <IServer>
            {
                new TestServer(new Mock <IEventAggregator>().Object, Guid.NewGuid(), CommonSetupHelper.CreateConnection(false).Object, new Mock <IResourceRepository>().Object, false)
            };

            serverProvider.Setup(s => s.Load()).Returns(environmentModels);
            IConnectControlSingleton connectControlSingleton = new ConnectControlSingleton(serverProvider.Object, environmentRepository.Object);
            var selectedServer = connectControlSingleton.Servers[1];

            selectedServer.IsConnected = false;

            var actualConnectedState = ConnectionEnumerations.ConnectedState.Disconnected;
            var actualDoCallback     = false;
            var environmentId        = Guid.Empty;

            connectControlSingleton.ConnectedStatusChanged += (sender, arg) =>
            {
                actualConnectedState = arg.ConnectedStatus;
                actualDoCallback     = arg.DoCallback;
                environmentId        = arg.EnvironmentId;
            };
            //------------Execute Test---------------------------
            connectControlSingleton.ToggleConnection(1);
            //------------Assert Results-------------------------
            Assert.IsNotNull(connectControlSingleton);
            Assert.AreEqual(ConnectionEnumerations.ConnectedState.Busy, actualConnectedState);
            Assert.IsFalse(actualDoCallback);
            Assert.AreEqual(selectedServer.Server.EnvironmentID, environmentId);
        }