Exemple #1
0
        public void AttributeIsInvalidWhenCollectionIsNullTest()
        {
            // arrange
            var attribute = new MaximumSize(2);

            // act
            var actual = attribute.IsValid(null);

            // assert
            Assert.False(actual);
        }
Exemple #2
0
        public void ErrorMessageTest()
        {
            // arrange
            long maxSize = new Random().Next(1, 10);
            var  expectedErrorMessage = $"{nameof(ErrorMessageTest)} can contain max {maxSize} elements.";

            // act
            var actual = new MaximumSize(maxSize);

            // assert
            StringAssert.AreEqualIgnoringCase(expectedErrorMessage, actual.ErrorMessage);
        }
Exemple #3
0
        public void AttributeIsInvalidTest()
        {
            // arrange
            var list = new List <string> {
                "test", "test", "test"
            };
            var attribute = new MaximumSize(2);

            // act
            var actual = attribute.IsValid(list);

            // assert
            Assert.False(actual);
        }
Exemple #4
0
        public override int GetHashCode()
        {
            StringBuilder builder = new StringBuilder();

            if (FontFamily != null)
            {
                builder.Append(FontFamily.ToString());
            }
            builder.Append(FontStyle.ToString());
            builder.Append(FontStretch.ToString());
            builder.Append(((ushort)FontWeight.Weight).ToString());
            builder.Append(WordWrap.ToString());
            builder.Append(MaximumSize.ToString());
            return(builder.ToString().GetHashCode());
        }
Exemple #5
0
        internal override void BuildNodes(System.Xml.XmlElement parent, System.Xml.XmlDocument doc)
        {
            XmlElement el = doc.CreateElement("DisplayWindow");

            XmlHelper.AppendAttribute(el, doc, "name", Name);
            XmlHelper.AppendAttribute(el, doc, "preferred_size", Size.ToString());
            XmlHelper.AppendAttribute(el, doc, "minimum_size", MinimumSize.ToString());
            XmlHelper.AppendAttribute(el, doc, "maximum_size", MaximumSize.ToString());
            XmlHelper.AppendAttribute(el, doc, "allow_resize", AllowResize);
            XmlHelper.AppendAttribute(el, doc, "full_screen", FullScreen);
            XmlHelper.AppendAttribute(el, doc, "bpp", Bpp);

            el.InnerText = Title;

            parent.AppendChild(el);
        }
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (LogName.Expression != null)
            {
                targetCommand.AddParameter("LogName", LogName.Get(context));
            }

            if (RetentionDays.Expression != null)
            {
                targetCommand.AddParameter("RetentionDays", RetentionDays.Get(context));
            }

            if (OverflowAction.Expression != null)
            {
                targetCommand.AddParameter("OverflowAction", OverflowAction.Get(context));
            }

            if (MaximumSize.Expression != null)
            {
                targetCommand.AddParameter("MaximumSize", MaximumSize.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }