Beispiel #1
0
        public CoreDaemonHostTestBase() : base()
        {
            DefaultDaemonApp = new BaseTestApp
            {
                Id        = "app_id",
                IsEnabled = true
            };

            DefaultDaemonHost.AddRunningApp(DefaultDaemonApp);

            DefaultDaemonRxApp = new BaseTestRxApp
            {
                Id        = "app_rx_id",
                IsEnabled = true
            };
            DefaultDaemonHost.AddRunningApp(DefaultDaemonRxApp);

            DefaultMockedRxApp = new Mock <NetDaemonRxApp>()
            {
                CallBase = true
            };
            DefaultMockedRxApp.Object.Id        = "app_rx_mock_id";
            DefaultMockedRxApp.Object.IsEnabled = true;
            DefaultMockedRxApp.Setup(n => n.CreateObservableIntervall(It.IsAny <TimeSpan>(), It.IsAny <Action>())).Returns(new Mock <IDisposable>().Object);

            DefaultDaemonHost.AddRunningApp(DefaultMockedRxApp.Object);

            var notConnectedHassClientFactoryMock = new HassClientFactoryMock(HassClientMock.MockConnectFalse);

            _notConnectedDaemonHost = new NetDaemonHost(notConnectedHassClientFactoryMock.Object, DefaultDataRepositoryMock.Object, LoggerMock.LoggerFactory);

            SetupFakeData();
        }
Beispiel #2
0
        public ApiFakeStartup(IConfiguration configuration)
        {
            Configuration              = configuration;
            _loggerMock                = new LoggerMock();
            _defaultHassClientMock     = HassClientMock.DefaultMock;
            _defaultDataRepositoryMock = new Mock <IDataRepository>();
            _defaultHttpHandlerMock    = new HttpHandlerMock();
            var hassClientFactoryMock = new HassClientFactoryMock(_defaultHassClientMock);

            _defaultDaemonHost = new NetDaemonHost(
                hassClientFactoryMock.Object,
                _defaultDataRepositoryMock.Object,
                _loggerMock.LoggerFactory,
                _defaultHttpHandlerMock.Object);

            _defaultDaemonApp = new BaseTestApp
            {
                Id        = "app_id",
                IsEnabled = true
            };

            _defaultDaemonHost.AddRunningApp(_defaultDaemonApp);

            _defaultDaemonApp2 = new BaseTestApp
            {
                Id = "app_id2"
            };
            _defaultDaemonApp2.RuntimeInfo.NextScheduledEvent = DateTime.Now;
            _defaultDaemonApp2.IsEnabled = false;
            _defaultDaemonHost.AddRunningApp(_defaultDaemonApp2);

            _defaultDaemonRxApp = new BaseTestRxApp
            {
                Id        = "app_rx_id",
                IsEnabled = true
            };
            _defaultDaemonRxApp.RuntimeInfo.NextScheduledEvent = DateTime.Now;
            _defaultDaemonHost.AddRunningApp(_defaultDaemonRxApp);

            _defaultMockedRxApp = new Mock <NetDaemonRxApp>()
            {
                CallBase = true
            };
            _defaultMockedRxApp.Object.Id        = "app_rx_mock_id";
            _defaultMockedRxApp.Object.IsEnabled = true;
            _defaultMockedRxApp.Setup(n => n.CreateObservableIntervall(It.IsAny <TimeSpan>(), It.IsAny <Action>())).Returns(new Mock <IDisposable>().Object);
            _defaultDaemonHost.AddRunningApp(_defaultMockedRxApp.Object);
        }
Beispiel #3
0
        public ApiFakeStartup(IConfiguration configuration)
        {
            Configuration              = configuration;
            _loggerMock                = new LoggerMock();
            _defaultHassClientMock     = HassClientMock.DefaultMock;
            _defaultDataRepositoryMock = new Mock <IDataRepository>();
            _defaultHttpHandlerMock    = new HttpHandlerMock();
            var hassClientFactoryMock = new HassClientFactoryMock(_defaultHassClientMock);

            _defaultDaemonHost = new NetDaemonHost(
                hassClientFactoryMock.Object,
                _defaultDataRepositoryMock.Object,
                _loggerMock.LoggerFactory,
                _defaultHttpHandlerMock.Object);

            _defaultDaemonApp = new BaseTestApp
            {
                Id        = "app_id",
                IsEnabled = true
            };
            _defaultDaemonHost.InternalRunningAppInstances[_defaultDaemonApp.Id !] = _defaultDaemonApp;