public void DisconnectTest()
 {
     try
     {
         var notConnectedState = new CameraNotConnectedState(It.IsAny <IExtendedCamera>(), It.IsAny <IProxyFactory>());
         notConnectedState.Disconnect();
     }
     catch (Exception e)
     {
         Assert.AreEqual(typeof(IncorrectCameraStateException), e.GetType());
         return;
     }
 }
        public void ConnectionTest()
        {
            var serviceMock      = new Mock <Device>();
            var cameraMock       = new Mock <IExtendedCamera>();
            var proxyFactoryMock = new Mock <IProxyFactory>();

            serviceMock.Setup(x => x.GetSystemDateAndTimeAsync()).ReturnsAsync(new SystemDateTime());
            proxyFactoryMock.Setup(x => x.Create <Device, DeviceClient>(It.IsAny <Uri>())).Returns(() => serviceMock.Object);

            var notConnectedState = new CameraNotConnectedState(cameraMock.Object, proxyFactoryMock.Object);

            notConnectedState.Connect();

            cameraMock.VerifySet(x => x.StateObject = It.Is <ICameraState>(y => y.GetType() == typeof(CameraConnectedState)));
        }
        public void ThrowExceptionWhileConnectingTest()
        {
            var serviceMock      = new Mock <Device>();
            var cameraMock       = new Mock <IExtendedCamera>();
            var proxyFactoryMock = new Mock <IProxyFactory>();

            serviceMock.Setup(x => x.GetSystemDateAndTimeAsync()).ThrowsAsync(new EndpointNotFoundException());
            proxyFactoryMock.Setup(x => x.Create <Device, DeviceClient>(It.IsAny <Uri>())).Returns(() => serviceMock.Object);

            try
            {
                var notConnectedState = new CameraNotConnectedState(cameraMock.Object, proxyFactoryMock.Object);
                notConnectedState.Connect();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(CameraConnectionException), e.GetType());
                return;
            }

            Assert.Fail();
        }
Beispiel #4
0
 public Camera()
 {
     _proxyFactory = new ProxyFactory();
     StateObject   = new CameraNotConnectedState(this, _proxyFactory);
 }