public void ApplyIfNull( ConditionMonitor sut )
		{
			var count = 0;

			Assert.True( sut.ApplyIf( null, () => count++ ) );

			Assert.Equal( 1, count );
		}
 public InnerContent(IInnerContent content, ConditionMonitor monitor, bool apply)
 {
     _content = content;
     _monitor = monitor;
     if (apply)
     {
         monitor.Apply();
     }
 }
		public void ApplyWithAction( ConditionMonitor sut )
		{
			var count = 0;

			Assert.True( sut.Apply( () => count++ ) );

			Assert.Equal( 1, count );

			Assert.False( sut.Apply( () => count++ ) );

			Assert.Equal( 1, count );
		}
            public IInnerContent Get(IFormatReader parameter)
            {
                var monitor = new ConditionMonitor();

                if (_apply)
                {
                    monitor.Apply();
                }

                var result = new InnerContent(_activator.Get(parameter), monitor);

                return(result);
            }
		public void ApplyIf( ConditionMonitor sut )
		{
			var count = 0;

			Assert.False( sut.ApplyIf( false, () => count++ ) );
			
			Assert.Equal( 0, count );

			Assert.True( sut.ApplyIf( true, () => count++ ) );

			Assert.Equal( 1, count );

			Assert.False( sut.ApplyIf( true, () => count++ ) );
		}
		public void Apply( ConditionMonitor sut )
		{
			Assert.False( sut.State == ConditionMonitorState.Applied );

			var applied = sut.Apply();

			Assert.True( applied );
			Assert.True( sut.State == ConditionMonitorState.Applied );


			Assert.False( sut.Apply() );
			
			sut.Reset();

			Assert.False( sut.State == ConditionMonitorState.Applied );
		}
 public InnerContent(IInnerContent content, ConditionMonitor monitor)
 {
     _content = content;
     _monitor = monitor;
 }
Esempio n. 8
0
 public ConditionalSpecification(ConditionMonitor monitor) => _monitor = monitor;
Esempio n. 9
0
 /// <summary>
 /// Save the object's XML to the XmlWriter.
 /// </summary>
 /// <param name="objWriter">XmlTextWriter to write with.</param>
 public new void Print(XmlTextWriter objWriter)
 {
     objWriter.WriteStartElement("gear");
     objWriter.WriteElementString("name", DisplayNameShort);
     objWriter.WriteElementString("name_english", _strName);
     if (DisplayCategory.EndsWith("s"))
     {
         objWriter.WriteElementString("category", DisplayCategory.Substring(0, DisplayCategory.Length - 1));
     }
     else
     {
         objWriter.WriteElementString("category", DisplayCategory);
     }
     objWriter.WriteElementString("category_english", _strCategory);
     objWriter.WriteElementString("iscommlink", true.ToString());
     objWriter.WriteElementString("ispersona", IsLivingPersona.ToString());
     //objWriter.WriteElementString("isnexus", (_strCategory == "Nexus").ToString());
     objWriter.WriteElementString("isammo", (_strCategory == "Ammunition").ToString());
     objWriter.WriteElementString("isprogram", IsProgram.ToString());
     objWriter.WriteElementString("isos", false.ToString());
     objWriter.WriteElementString("issin", false.ToString());
     objWriter.WriteElementString("maxrating", _intMaxRating.ToString());
     objWriter.WriteElementString("rating", _intRating.ToString());
     objWriter.WriteElementString("attack", _intAttack.ToString());
     objWriter.WriteElementString("sleaze", _intSleaze.ToString());
     objWriter.WriteElementString("dataprocessing", _intDataProcessing.ToString());
     objWriter.WriteElementString("firewall", _intFirewall.ToString());
     objWriter.WriteElementString("qty", _intQty.ToString());
     objWriter.WriteElementString("avail", TotalAvail(true));
     objWriter.WriteElementString("avail_english", TotalAvail(true, true));
     objWriter.WriteElementString("cost", TotalCost.ToString());
     objWriter.WriteElementString("owncost", OwnCost.ToString());
     objWriter.WriteElementString("extra", LanguageManager.Instance.TranslateExtra(_strExtra));
     objWriter.WriteElementString("bonded", _blnBonded.ToString());
     objWriter.WriteElementString("equipped", _blnEquipped.ToString());
     objWriter.WriteElementString("homenode", _blnHomeNode.ToString());
     objWriter.WriteElementString("gearname", _strGearName);
     objWriter.WriteElementString("source", _objCharacter.Options.LanguageBookShort(_strSource));
     objWriter.WriteElementString("page", Page);
     objWriter.WriteElementString("devicerating", TotalDeviceRating.ToString());
     objWriter.WriteElementString("processorlimit", ProcessorLimit.ToString());
     objWriter.WriteElementString("conditionmonitor", ConditionMonitor.ToString());
     objWriter.WriteElementString("active", _blnActiveCommlink.ToString());
     objWriter.WriteStartElement("children");
     foreach (Gear objGear in _objChildren)
     {
         if (objGear.Category != "Commlink Upgrade" && objGear.Category != "Commlink Operating System Upgrade")
         {
             // Use the Gear's SubClass if applicable.
             if (objGear.GetType() == typeof(Commlink))
             {
                 Commlink objCommlink = new Commlink(_objCharacter);
                 objCommlink = (Commlink)objGear;
                 objCommlink.Print(objWriter);
             }
             else
             {
                 objGear.Print(objWriter);
             }
         }
     }
     objWriter.WriteEndElement();
     if (_objCharacter.Options.PrintNotes)
     {
         objWriter.WriteElementString("notes", _strNotes);
     }
     objWriter.WriteEndElement();
 }