当前位置: 首页>>代码示例>>C#>>正文


C# TestContext.ExecuteCommand方法代码示例

本文整理汇总了C#中TestContext.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.ExecuteCommand方法的具体用法?C# TestContext.ExecuteCommand怎么用?C# TestContext.ExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestContext的用法示例。


在下文中一共展示了TestContext.ExecuteCommand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanUploadToDirectAndLatestWithLongOptions

        public async Task CanUploadToDirectAndLatestWithLongOptions()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "--connection-string", tc.ConnectionString,
                        "--container", tc.Container,
                        "--path-format", tc.PathFormat
                    },
                    tc.Content);

                // Assert
                await tc.VerifyContentAsync(actual, direct: true, latest: true);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:19,代码来源:ProgramTests.cs

示例2: WritesHelpTextWithShortOptions

        public void WritesHelpTextWithShortOptions()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                // Act
                var actual = tc.ExecuteCommand(
                    new[] { "-h" },
                    tc.Content);

                // Assert
                Assert.Equal(CommandStatus.Exited, actual.Status);
                Assert.Equal(0, actual.ExitCode);
                Assert.Contains("Usage: ToStorage [options]", actual.Output);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:16,代码来源:ProgramTests.cs

示例3: RequiresContainerOption

        public void RequiresContainerOption()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "--connection-string", tc.ConnectionString,
                        "--path-format", tc.PathFormat
                    },
                    tc.Content);

                // Assert
                Assert.Equal(CommandStatus.Exited, actual.Status);
                Assert.Equal(1, actual.ExitCode);
                Assert.Contains("Error: required option -c, --container is missing.", actual.Error);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:20,代码来源:ProgramTests.cs

示例4: RequiresConnectionStringAndContainerOptions

        public void RequiresConnectionStringAndContainerOptions()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                // Act
                var actual = tc.ExecuteCommand(
                    Enumerable.Empty<string>(),
                    tc.Content);

                // Assert
                Assert.Equal(CommandStatus.Exited, actual.Status);
                Assert.Equal(1, actual.ExitCode);
                Assert.Contains("Error: required option -s, --connection-string is missing.", actual.Error);
                Assert.Contains("Error: required option -c, --container is missing.", actual.Error);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:17,代码来源:ProgramTests.cs

示例5: HasDefaultPathFormat

        public async Task HasDefaultPathFormat()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                var minTimestamp = DateTimeOffset.UtcNow;

                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "-s", tc.ConnectionString,
                        "-c", tc.Container
                    },
                    tc.Content);

                // Assert
                var maxTimestamp = DateTimeOffset.UtcNow;

                var result = await tc.VerifyContentAsync(actual, direct: true, latest: true);

                var directFileName = result.DirectUri.ToString().Split('/').Last();
                Assert.EndsWith(".txt", directFileName);
                var unparsedTimestamp = directFileName.Substring(0, directFileName.Length - ".txt".Length);
                var timestampLocal = DateTime.ParseExact(unparsedTimestamp, "yyyy.MM.dd.HH.mm.ss.fffffff", CultureInfo.InvariantCulture);
                var timestamp = new DateTimeOffset(timestampLocal, TimeSpan.Zero);
                Assert.True(timestamp >= minTimestamp, "The timestamp should be greater than or equal to the minimum.");
                Assert.True(timestamp <= maxTimestamp, "The timestamp should be less than or equal to the maximum.");

                Assert.EndsWith("/latest.txt", result.LatestUri.ToString());
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:32,代码来源:ProgramTests.cs

示例6: AllowsBothDirectAndLatestUploadToBeDisabled

        public async Task AllowsBothDirectAndLatestUploadToBeDisabled()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "-s", tc.ConnectionString,
                        "-c", tc.Container,
                        "-f", tc.PathFormat,
                        "--no-direct",
                        "--no-latest"
                    },
                    tc.Content);

                // Assert
                await tc.VerifyContentAsync(actual, direct: false, latest: false);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:21,代码来源:ProgramTests.cs

示例7: CanSetContentTypeWithLongOptions

        public async Task CanSetContentTypeWithLongOptions()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                tc.Content = "{\"foo\": 5}";
                tc.ContentType = "application/json";

                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "--connection-string", tc.ConnectionString,
                        "--container", tc.Container,
                        "--path-format", tc.PathFormat,
                        "--content-type", tc.ContentType
                    },
                    tc.Content);

                // Assert
                await tc.VerifyContentAsync(actual, direct: true, latest: true);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:23,代码来源:ProgramTests.cs

示例8: CanUploadOnlyLatestWithUniqueOnlyOption

        public async Task CanUploadOnlyLatestWithUniqueOnlyOption()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                tc.Content = "something";
                var initial = tc.ExecuteCommand(
                    new[]
                    {
                        "-s", tc.ConnectionString,
                        "-c", tc.Container,
                        "-f", tc.PathFormat,
                        "--no-direct"
                    },
                    tc.Content);

                tc.Content = "something else";

                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "--connection-string", tc.ConnectionString,
                        "--container", tc.Container,
                        "--path-format", tc.PathFormat,
                        "--no-direct",
                        "--only-unique"
                    },
                    tc.Content);

                // Assert
                await tc.VerifyContentAsync(actual, direct: false, latest: true);
                Assert.Contains("Gettings the existing latest... different! The provided content will be uploaded.", actual.Output);
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:35,代码来源:ProgramTests.cs

示例9: CanUploadOnlyWhenUniqueWithLongOptions

        public void CanUploadOnlyWhenUniqueWithLongOptions()
        {
            // Arrange
            using (var tc = new TestContext(_output))
            {
                var initial = tc.ExecuteCommand(
                    new[]
                    {
                        "-s", tc.ConnectionString,
                        "-c", tc.Container,
                        "-f", tc.PathFormat
                    },
                    tc.Content);

                // Act
                var actual = tc.ExecuteCommand(
                    new[]
                    {
                        "--connection-string", tc.ConnectionString,
                        "--container", tc.Container,
                        "--path-format", tc.PathFormat,
                        "--only-unique"
                    },
                    tc.Content);

                // Assert
                tc.VerifyCommandResult(actual);
                Assert.Equal("Gettings the existing latest... exactly the same! No upload required.", actual.Output.TrimEnd());
            }
        }
开发者ID:joelverhagen,项目名称:ToStorage,代码行数:30,代码来源:ProgramTests.cs


注:本文中的TestContext.ExecuteCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。