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);
}