Esempio n. 1
0
        public void Connect(string key)
        {
            if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));

            _credentialsRepository.SaveIfttt(key);

            if (_deviceRepository.Exists("IFTTT", DeviceCapability.WebService))
                return;

            var iftttService = new Device
            {
                Identifier = Guid.NewGuid(),
                Name = "IFTTT",
                Capability = DeviceCapability.WebService,
                Type = DeviceType.Ifttt
            };

            _deviceRepository.Add(iftttService);
        }
Esempio n. 2
0
        protected override void Arrange()
        {
            DataContextManager = new DataContextManager();
            DataContextManager.RefreshSettingsDataContext().Wait();

            var switchableDevice = new Device { Identifier = Guid.NewGuid(), Name = "switchable device", Capability = DeviceCapability.Switchable, Type = DeviceType.Fifthplay };
            var unsupportedDevice = new Device { Identifier = Guid.NewGuid(), Name = "unsupported device", Capability = DeviceCapability.None, Type = DeviceType.Ifttt };

            DataContextManager.SettingsDataContext.IsApplicationEnabled = true;
            DataContextManager.SettingsDataContext.Devices = new List<Device> { switchableDevice, unsupportedDevice };

            DataContextManager.SettingsDataContext.Actions = new List<Business.Model.Action>
            {
                new Business.Model.Action
                {
                    Identifier = Guid.NewGuid(),
                    DeviceIdentifier = switchableDevice.Identifier,
                    ActionTypeIdentifier = DataContextManager.SettingsDataContext.ActionTypes.First().Identifer,
                    ActionArgumentIdentifier = DataContextManager.SettingsDataContext.ActionTypes.First().ActionArguments.First().Identifer,
                    ActionTrigger = ActionTrigger.Home
                },
                new Business.Model.Action
                {
                    Identifier = Guid.NewGuid(),
                    DeviceIdentifier = unsupportedDevice.Identifier,
                    ActionTypeIdentifier = DataContextManager.SettingsDataContext.ActionTypes.First().Identifer,
                    ActionArgumentIdentifier = DataContextManager.SettingsDataContext.ActionTypes.First().ActionArguments.ElementAt(1).Identifer,
                    ActionTrigger = ActionTrigger.Away
                }
            };

            DataContextManager.SettingsDataContext.Logs.Add(new ActionLog { Identifier = Guid.NewGuid(), ActionArgumentValue = "on", Type = "Home", ActionTypeName = "switch", DeviceName = "dummy device", Timestamp = DateTimeOffset.UtcNow });
            DataContextManager.SettingsDataContext.Logs.Add(new ActionLog { Identifier = new Guid("6fd4aa18-e36c-493c-815d-d4e1e8ed675f"), ActionArgumentValue = "on", Type = "Home", ActionTypeName = "switch", DeviceName = "Desk lamp", Timestamp = DateTimeOffset.UtcNow });
            DataContextManager.SettingsDataContext.Logs.Add(new FailedActionLog { Identifier = Guid.NewGuid(), ActionArgumentValue = "on", Type = "Home", ActionTypeName = "switch", DeviceName = "dummy device", Timestamp = DateTimeOffset.UtcNow, Error = "dummy-error" });
            DataContextManager.SettingsDataContext.Logs.Add(new FailedActionLog { Identifier = Guid.NewGuid(), ActionArgumentValue = "on", Type = "Home", ActionTypeName = "switch", DeviceName = "dummy device", Timestamp = DateTimeOffset.UtcNow, Error = "dummy-error" });
            DataContextManager.SettingsDataContext.Logs.Add(new ExceptionLog { Identifier = Guid.NewGuid(), Error = new Exception().ToString(), Timestamp = DateTimeOffset.UtcNow });
            DataContextManager.SettingsDataContext.Logs.Add(new ExceptionLog { Identifier = Guid.NewGuid(), Error = "dummy-error", Timestamp = DateTimeOffset.UtcNow });
        }
Esempio n. 3
0
        public void Add(Device device)
        {
            if (device == null) throw new ArgumentNullException(nameof(device));

            DataContext.Devices.Add(device);
        }
Esempio n. 4
0
 private void AssertDevice(Device original, Device compare)
 {
     Assert.IsNotNull(compare);
     Assert.AreEqual(original.Identifier, compare.Identifier);
     Assert.AreEqual(original.Name, compare.Name);
     Assert.AreEqual(original.Capability, compare.Capability);
 }
 public void Add(Device device)
 {
 }