Ejemplo n.º 1
0
            public void ContextSetup()
            {
                var groupId = Guid.NewGuid();

                _masterModel = new MasterModel();
                var project = _masterModel.CreateProject(x => x.Name = "Existing Project");

                project.CreateGroup(x => x.Id = groupId)
                .AddLight(new Light(new ZWaveValueIdentity(1, 11, 123)))
                .AddLight(new Light(new ZWaveValueIdentity(1, 12, 123)));

                _zWaveIdentity = new ZWaveValueIdentity(1, 14, 123);
                var unassignedLights = new[]
                {
                    new Light(new ZWaveValueIdentity(1, 51, 123)),
                    new Light(_zWaveIdentity),
                    new Light(new ZWaveValueIdentity(1, 53, 123))
                };

                _masterModel.AddUnassignedLights(unassignedLights);

                var repository = S <IMasterModelRepository>();

                repository.Stub(x => x.GetCurrent()).Return(_masterModel);

                var updater = new LightModelUpdater(repository);

                updater.Update(_zWaveIdentity, groupId, LightColor.Red.Value);
            }
 public void SetUnassignedLights(MasterModel masterModel)
 {
     if (!_initialized)
     {
         throw new InvalidOperationException("The stub is not initialized.");
     }
     masterModel.AddUnassignedLights(_stubbed);
 }
Ejemplo n.º 3
0
            public void ContextSetup()
            {
                var model = new MasterModel();
                var group = model.CreateProject().CreateGroup();

                _identity1 = new ZWaveValueIdentity(1, 11, 123);
                _identity2 = new ZWaveValueIdentity(2, 22, 123);
                _identity3 = new ZWaveValueIdentity(3, 33, 123);
                _identity4 = new ZWaveValueIdentity(4, 44, 123);

                group
                .AddLight(new Light(_identity1))
                .AddLight(new Light(_identity2));
                model.AddUnassignedLights(new[] { new Light(_identity3), new Light(_identity4) });

                _result = model.AllLights;
            }
Ejemplo n.º 4
0
        public void SetUnassignedLights(MasterModel masterModel)
        {
            var allLights   = masterModel.AllLights;
            var allSwitches = _network.GetAllSwitches();

            var switchesAlreadyInAProject = allSwitches
                                            .Where(sw =>
                                                   allLights.Any(l =>
            {
                var lightIdentity  = l.ZWaveIdentity;
                var switchIdentity = sw.ZWaveIdentity;
                return(lightIdentity.Equals(switchIdentity));
            })
                                                   ).ToArray();

            var newSwitches = allSwitches.Except(switchesAlreadyInAProject);
            var newLights   = newSwitches.Select(x => new Light(x.ZWaveIdentity)).ToArray();

            masterModel.AddUnassignedLights(newLights);
        }
Ejemplo n.º 5
0
        public MasterModel ToDomainObject()
        {
            var masterModel = new MasterModel
            {
                LastUpdatedDate = LastUpdatedDate,
            };

            foreach (var jsonProject in Projects)
            {
                masterModel.CreateProject(jsonProject.InitializeDomainObject());
            }
            foreach (var jsonCruiseServer in CruiseServers)
            {
                masterModel.CreateCruiseServer(jsonCruiseServer.InitializeDomainObject());
            }

            var unassignedLights = UnassignedLights ?? new JsonLight[0];

            masterModel.AddUnassignedLights(unassignedLights.Select(x => x.ToDomainObject()));
            return(masterModel);
        }