public void SetConnectionState(Guid environmentId, ConnectionEnumerations.ConnectedState connectedState)
 {
     if (ConnectedStatusChanged != null)
     {
         ConnectedStatusChanged(this, new ConnectionStatusChangedEventArg(connectedState, environmentId, false));
     }
 }
예제 #2
0
        public void ConnectControlSingleton_ToggleConnection_SelectedServerIsDisconnected_StudioRepositoryLoadIsCalled()
        {
            var            serverProvider        = new Mock <IEnvironmentModelProvider>();
            var            environmentRepository = new Mock <IServerRepository>();
            List <IServer> environmentModels     = new List <IServer>
            {
                new TestServer(new Mock <IEventAggregator>().Object, Guid.NewGuid(), 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;

            ConnectionEnumerations.ConnectedState actualConnectedState = ConnectionEnumerations.ConnectedState.Disconnected;
            bool actualDoCallback = false;
            Guid 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);
        }
        public void ConnectControlSingleton_SetConnectionState_WhenThereIsASubscriber_RaisesAnEvent()
        {
            var serverProvider    = new Mock <IEnvironmentModelProvider>();
            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);
            var environmentRepository = new Mock <IServerRepository>();
            var expectedServerId      = Guid.NewGuid();
            var actualId = Guid.Empty;
            const ConnectionEnumerations.ConnectedState expectedConnectedState = ConnectionEnumerations.ConnectedState.Busy;
            var actualConnectedState = ConnectionEnumerations.ConnectedState.Disconnected;
            IConnectControlSingleton connectControlSingleton = new ConnectControlSingleton(serverProvider.Object, environmentRepository.Object);

            connectControlSingleton.ConnectedStatusChanged += (s, a) =>
            {
                actualId             = a.EnvironmentId;
                actualConnectedState = a.ConnectedStatus;
            };
            //------------Execute Test---------------------------
            connectControlSingleton.SetConnectionState(expectedServerId, expectedConnectedState);
            //------------Assert Results-------------------------
            Assert.AreEqual(expectedServerId, actualId);
            Assert.AreEqual(expectedConnectedState, actualConnectedState);
        }
예제 #4
0
        public void ConnectControlSingleton_EditConnection_AuthChangedOnTheDialog_StudioResourceRepositoryLoadIsCalled()
        {
            var serverProvider    = new Mock <IEnvironmentModelProvider>();
            var server1           = Guid.NewGuid();
            var server2           = Guid.NewGuid();
            var environmentModels = new List <IServer>
            {
                new TestServer(new Mock <IEventAggregator>().Object, server1, CreateConnection(false).Object, new Mock <IResourceRepository>().Object, false),
                new TestServer(new Mock <IEventAggregator>().Object, server2, CreateConnection(false).Object, new Mock <IResourceRepository>().Object, false)
            };
            var environmentRepository = new Mock <IServerRepository>();
            var environments          = new List <IServer>
            {
                new TestServer(new Mock <IEventAggregator>().Object, server1, CreateConnection(false, new Uri("http://localhost:3142/dsf"), AuthenticationType.Anonymous).Object, new Mock <IResourceRepository>().Object, false),
                new TestServer(new Mock <IEventAggregator>().Object, server2, CreateConnection(false, new Uri("http://localhost:3142/dsf"), AuthenticationType.Public).Object, new Mock <IResourceRepository>().Object, false)
            };

            environmentRepository.Setup(e => e.All()).Returns(environments);
            serverProvider.Setup(s => s.Load()).Returns(environmentModels);
            IConnectControlSingleton connectControlSingleton = new ConnectControlSingleton(serverProvider.Object, environmentRepository.Object);
            var selectedIndex = -1;

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

            connectControlSingleton.ConnectedStatusChanged += (sender, arg) =>
            {
                actualConnectedState = arg.ConnectedStatus;
                actualDoCallback     = arg.DoCallback;
                environmentId        = arg.EnvironmentId;
            };
            //------------Execute Test---------------------------
            connectControlSingleton.EditConnection(1, index =>
            {
                selectedIndex = index;
            });
            //------------Assert Results-------------------------
            Assert.IsNotNull(connectControlSingleton);
            Assert.AreEqual(ConnectionEnumerations.ConnectedState.Busy, actualConnectedState);
            Assert.IsFalse(actualDoCallback);
            Assert.AreEqual(server1, environmentId);
            Assert.AreEqual(1, selectedIndex);
        }
예제 #5
0
 public ConnectionStatusChangedEventArg(ConnectionEnumerations.ConnectedState connectedStatus, Guid environmentId, bool doCallback)
 {
     ConnectedStatus = connectedStatus;
     EnvironmentId   = environmentId;
     DoCallback      = doCallback;
 }