示例#1
0
        public void Rules_CrazinessRule_Value()
        {
            var        dateTime = new DateTime(1994, 1, 5, 10, 10, 10);
            Tamagotchi t        = new Tamagotchi(0, 95, 0, 0, dateTime, TimeSpan.Zero);

            Rule rule = new CrazinessRule();
            Rule iso  = new IsolationRule();

            rule.Execute(t, dateTime);
            Assert.IsFalse(t.IsCrazy);

            iso.Execute(t, dateTime + TimeSpan.FromHours(2));
            rule.Execute(t, dateTime + TimeSpan.FromHours(2));
            Assert.IsTrue(t.IsCrazy);
        }
示例#2
0
        /// <summary>
        /// Serializes this instance of <see cref="NetworkSecurityRuleResources" /> into a <see cref="Carbon.Json.JsonNode" />.
        /// </summary>
        /// <param name="container">The <see cref="Carbon.Json.JsonObject"/> container to serialize this object into. If the caller
        /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param>
        /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Rest.ClientRuntime.SerializationMode"/>.</param>
        /// <returns>
        /// a serialized instance of <see cref="NetworkSecurityRuleResources" /> as a <see cref="Carbon.Json.JsonNode" />.
        /// </returns>
        public Carbon.Json.JsonNode ToJson(Carbon.Json.JsonObject container, Microsoft.Rest.ClientRuntime.SerializationMode serializationMode)
        {
            container = container ?? new Carbon.Json.JsonObject();

            bool returnNow = false;

            BeforeToJson(ref container, ref returnNow);
            if (returnNow)
            {
                return(container);
            }
            AddIf(null != AppRule ? (Carbon.Json.JsonNode)AppRule.ToJson(null) : null, "app_rule", container.Add);
            AddIf(null != IsolationRule ? (Carbon.Json.JsonNode)IsolationRule.ToJson(null) : null, "isolation_rule", container.Add);
            AddIf(null != QuarantineRule ? (Carbon.Json.JsonNode)QuarantineRule.ToJson(null) : null, "quarantine_rule", container.Add);
            AfterToJson(ref container);
            return(container);
        }