public void CombinedComponent_TurnOnAndOff() { var lamp1 = new Lamp("Lamp1", new TestLampAdapter()); var lamp2 = new Lamp("Lamp2", new TestLampAdapter()); var lamp3 = new Lamp("Lamp3", new TestLampAdapter()); var logicalComponent = new LogicalComponent("Test"); logicalComponent.WithComponent(lamp1); logicalComponent.WithComponent(lamp2); logicalComponent.WithComponent(lamp3); logicalComponent.ExecuteCommand(new TurnOffCommand()); Assert.IsTrue(logicalComponent.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp1.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp2.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp3.GetState().Has(PowerState.Off)); logicalComponent.ExecuteCommand(new TurnOnCommand()); Assert.IsTrue(logicalComponent.GetState().Has(PowerState.On)); Assert.IsTrue(lamp1.GetState().Has(PowerState.On)); Assert.IsTrue(lamp2.GetState().Has(PowerState.On)); Assert.IsTrue(lamp3.GetState().Has(PowerState.On)); logicalComponent.ExecuteCommand(new TurnOffCommand()); Assert.IsTrue(logicalComponent.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp1.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp2.GetState().Has(PowerState.Off)); Assert.IsTrue(lamp3.GetState().Has(PowerState.Off)); }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("TDDISystemUnion"); oprot.WriteStructBegin(struc); TField field = new TField(); if (System != null && __isset.System) { field.Name = "System"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); System.Write(oprot); oprot.WriteFieldEnd(); } if (PhysicalComponent != null && __isset.PhysicalComponent) { field.Name = "PhysicalComponent"; field.Type = TType.Struct; field.ID = 2; oprot.WriteFieldBegin(field); PhysicalComponent.Write(oprot); oprot.WriteFieldEnd(); } if (LogicalComponent != null && __isset.LogicalComponent) { field.Name = "LogicalComponent"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); LogicalComponent.Write(oprot); oprot.WriteFieldEnd(); } if (SafetyRelatedSystem != null && __isset.SafetyRelatedSystem) { field.Name = "SafetyRelatedSystem"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); SafetyRelatedSystem.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }
public LogicalComponent RegisterLogicalComponent(IArea area, Enum id) { if (area == null) { throw new ArgumentNullException(nameof(area)); } var component = new LogicalComponent($"{area.Id}.{id}"); area.RegisterComponent(component); return(component); }
public override string ToString() { StringBuilder __sb = new StringBuilder("TDDISystemUnion("); bool __first = true; if (System != null && __isset.System) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("System: "); __sb.Append(System == null ? "<null>" : System.ToString()); } if (PhysicalComponent != null && __isset.PhysicalComponent) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("PhysicalComponent: "); __sb.Append(PhysicalComponent == null ? "<null>" : PhysicalComponent.ToString()); } if (LogicalComponent != null && __isset.LogicalComponent) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("LogicalComponent: "); __sb.Append(LogicalComponent == null ? "<null>" : LogicalComponent.ToString()); } if (SafetyRelatedSystem != null && __isset.SafetyRelatedSystem) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("SafetyRelatedSystem: "); __sb.Append(SafetyRelatedSystem == null ? "<null>" : SafetyRelatedSystem.ToString()); } __sb.Append(")"); return(__sb.ToString()); }