Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
test_ArgumentToVersionTransformationAttribute.cs52 linesDownload Raw Back to csharp
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System;5using System.Collections.Generic;6using System.Management.Automation;7 8using Xunit;9 10namespace PSTests.Parallel11{12    public class ArgumentToVersionTransformationAttributeTests13    {14        [Theory]15        [MemberData(nameof(TestCases))]16        public void TestConversion(object inputData, object expected)17        {18            var transformation = new ArgumentToVersionTransformationAttribute();19            var result = transformation.Transform(default, inputData);20 21            Assert.Equal(expected, result);22        }23 24        public static IEnumerable<object[]> TestCases()25        {26            // strings27            yield return new object[] { "1.1", "1.1" };28            yield return new object[] { "1", new Version(1, 0) };29            yield return new object[] { string.Empty, new Version(0, 0) };30 31            // doubles32            yield return new object[] { 1.0, 1.0 };33            yield return new object[] { 1.1, 1.1 };34 35            // ints36            yield return new object[] { 1, new Version(1, 0) };37            yield return new object[] { 2, new Version(2, 0) };38 39            // PSObjects40            yield return new object[] { new PSObject(obj: 0), new Version(0, 0) };41            yield return new object[] { new PSObject(obj: 1), new Version(1, 0) };42 43            // unhandled44            var obj = new object();45            yield return new object[] { obj, obj };46 47            var date = DateTimeOffset.UtcNow;48            yield return new object[] { date, date };49        }50    }51}52