Dev2.ConnectionHelpers.ConnectControlSingleton.SetConnectionState C# (CSharp) Method

SetConnectionState() public method

public SetConnectionState ( System.Guid environmentId, ConnectionEnumerations connectedState ) : void
environmentId System.Guid
connectedState ConnectionEnumerations
return void
        public void SetConnectionState(Guid environmentId, ConnectionEnumerations.ConnectedState connectedState)
        {
            if(ConnectedStatusChanged != null)
            {
                ConnectedStatusChanged(this, new ConnectionStatusChangedEventArg(connectedState, environmentId, false));
            }
        }

Usage Example

 public void ConnectControlSingleton_SetConnectionState_WhenThereIsASubscriber_RaisesAnEvent()
 {
     var studioResourceRepository = new Mock<IStudioResourceRepository>();
     var asyncWorker = new Mock<IAsyncWorker>();
     var serverProvider = new Mock<IEnvironmentModelProvider>();
     List<IEnvironmentModel> environmentModels = new List<IEnvironmentModel>
         {
             new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(false).Object, new Mock<IResourceRepository>().Object, false)
         };
     serverProvider.Setup(s => s.Load()).Returns(environmentModels);
     var environmentRepository = new Mock<IEnvironmentRepository>();
     var expectedServerId = Guid.NewGuid();
     var actualId = Guid.Empty;
     const ConnectionEnumerations.ConnectedState expectedConnectedState = ConnectionEnumerations.ConnectedState.Busy;
     ConnectionEnumerations.ConnectedState actualConnectedState = ConnectionEnumerations.ConnectedState.Disconnected;
     IConnectControlSingleton connectControlSingleton = new ConnectControlSingleton(studioResourceRepository.Object, asyncWorker.Object, 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);
 }