本文整理汇总了C#中Xunit类的典型用法代码示例。如果您正苦于以下问题:C# Xunit类的具体用法?C# Xunit怎么用?C# Xunit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Xunit类属于命名空间,在下文中一共展示了Xunit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAzureRmAutoscaleSettingTests
public AddAzureRmAutoscaleSettingTests(Xunit.Abstractions.ITestOutputHelper output)
{
//ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
insightsAutoscaleOperationsMock = new Mock<IAutoscaleSettingsOperations>();
insightsManagementClientMock = new Mock<InsightsManagementClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new AddAzureRmAutoscaleSettingCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsManagementClient = insightsManagementClientMock.Object
};
response = new AzureOperationResponse<AutoscaleSettingResource>()
{
Body = new AutoscaleSettingResource()
};
insightsAutoscaleOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<AutoscaleSettingResource>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<Microsoft.Rest.Azure.AzureOperationResponse<AutoscaleSettingResource>>(response))
.Callback((string resourceGrp, string settingNm, AutoscaleSettingResource createOrUpdateParams, Dictionary<string, List<string>> headers, CancellationToken t) =>
{
resourceGroup = resourceGrp;
settingName = settingNm;
createOrUpdatePrms = createOrUpdateParams;
});
insightsManagementClientMock.SetupGet(f => f.AutoscaleSettings).Returns(this.insightsAutoscaleOperationsMock.Object);
}
示例2: EnumerateTestCommands
protected override System.Collections.Generic.IEnumerable<Xunit.Sdk.ITestCommand> EnumerateTestCommands(Xunit.Sdk.IMethodInfo method)
{
return base.EnumerateTestCommands(method).Select(enumerateTestCommand => new ActionTestCommandWrapper(enumerateTestCommand, o =>
{
((ReplicateToSql)o).ConnectionString=connectionStringSettings;
}));
}
示例3: GetAzureRmUsageTests
public GetAzureRmUsageTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
insightsUsageMetricOperationsMock = new Mock<IUsageMetricsOperations>();
insightsClientMock = new Mock<InsightsClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new GetAzureRmUsageCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsClient = insightsClientMock.Object
};
response = Utilities.InitializeUsageMetricResponse();
insightsUsageMetricOperationsMock
.Setup(f => f.ListAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<UsageMetricListResponse>(response))
.Callback((string f, string s, string a, CancellationToken t) =>
{
resourceId = f;
filter = s;
apiVersion = a;
});
insightsClientMock
.SetupGet(f => f.UsageMetricOperations)
.Returns(this.insightsUsageMetricOperationsMock.Object);
}
示例4: GetAzureRmUsageTests
public GetAzureRmUsageTests(Xunit.Abstractions.ITestOutputHelper output)
{
//ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
insightsUsageMetricOperationsMock = new Mock<IUsageMetricsOperations>();
insightsClientMock = new Mock<InsightsClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new GetAzureRmUsageCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsClient = insightsClientMock.Object
};
response = new Microsoft.Rest.Azure.AzureOperationResponse<IEnumerable<UsageMetric>>()
{
Body = new List<UsageMetric>()
};
insightsUsageMetricOperationsMock
.Setup(f => f.ListWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<ODataQuery<UsageMetric>>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<Microsoft.Rest.Azure.AzureOperationResponse<IEnumerable<UsageMetric>>>(response))
.Callback((string r, string api, ODataQuery<UsageMetric> q, Dictionary<string, List<string>> headers, CancellationToken t) =>
{
resourceId = r;
filter = q;
apiVersion = api;
});
insightsClientMock
.SetupGet(f => f.UsageMetrics)
.Returns(this.insightsUsageMetricOperationsMock.Object);
}
示例5: GetAzureRmAutoscaleSettingTests
public GetAzureRmAutoscaleSettingTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
insightsAutoscaleOperationsMock = new Mock<IAutoscaleOperations>();
insightsManagementClientMock = new Mock<InsightsManagementClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new GetAzureRmAutoscaleSettingCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsManagementClient = insightsManagementClientMock.Object
};
response = new AutoscaleSettingGetResponse()
{
RequestId = Guid.NewGuid().ToString(),
StatusCode = HttpStatusCode.OK,
Id = "",
Location = "",
Name = "",
Properties = null,
Tags = null,
};
responseList = new AutoscaleSettingListResponse()
{
RequestId = Guid.NewGuid().ToString(),
StatusCode = HttpStatusCode.OK,
AutoscaleSettingResourceCollection = new AutoscaleSettingResourceCollection()
{
Value = new List<AutoscaleSettingResource>()
{
new AutoscaleSettingResource(){
Id = "",
Location = "",
Name = "",
Properties = null,
Tags = null,
},
}
}
};
insightsAutoscaleOperationsMock.Setup(f => f.GetSettingAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<AutoscaleSettingGetResponse>(response))
.Callback((string resourceGrp, string settingNm, CancellationToken t) =>
{
resourceGroup = resourceGrp;
settingName = settingNm;
});
insightsAutoscaleOperationsMock.Setup(f => f.ListSettingsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<AutoscaleSettingListResponse>(responseList))
.Callback((string resourceGrp, string targetResourceId, CancellationToken t) =>
{
resourceGroup = resourceGrp;
targetResourceUri = targetResourceId;
});
insightsManagementClientMock.SetupGet(f => f.AutoscaleOperations).Returns(this.insightsAutoscaleOperationsMock.Object);
}
示例6: RemoveAzureRmAutoscaleSettingTests
public RemoveAzureRmAutoscaleSettingTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
insightsAutoscaleOperationsMock = new Mock<IAutoscaleOperations>();
insightsManagementClientMock = new Mock<InsightsManagementClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new RemoveAzureRmAutoscaleSettingCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsManagementClient = insightsManagementClientMock.Object
};
response = new AzureOperationResponse()
{
RequestId = Guid.NewGuid().ToString(),
StatusCode = HttpStatusCode.OK,
};
insightsAutoscaleOperationsMock.Setup(f => f.DeleteSettingAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<AzureOperationResponse>(response))
.Callback((string resourceGrp, string settingNm, CancellationToken t) =>
{
resourceGroup = resourceGrp;
settingName = settingNm;
});
insightsManagementClientMock.SetupGet(f => f.AutoscaleOperations).Returns(this.insightsAutoscaleOperationsMock.Object);
}
示例7: Y2016_Day12_Process_Returns_Correct_Solution
public static void Y2016_Day12_Process_Returns_Correct_Solution()
{
// Arrange
string[] instructions = new[]
{
"cpy 41 a",
"inc a",
"inc a",
"dec a",
"jnz a 2",
"dec a",
};
int[] binsOfInterest = new[] { 0, 1, 2 };
// Act
var actual = Day12.Process(instructions, initialValueOfC: 0);
// Assert
Assert.NotNull(actual);
Assert.Equal(4, actual.Count);
Assert.Equal(42, actual['a']);
Assert.Equal(0, actual['b']);
Assert.Equal(0, actual['c']);
Assert.Equal(0, actual['d']);
}
示例8: AddQueryListMultipleNullItem
public void AddQueryListMultipleNullItem()
{
var list = new[] { "test1", null, "test3" };
var url = UrlBuilder.Create("test").AddQuery("name", "value").AddQueryList("test", list).Url;
Assert.Equal("test?name=value&test=test1&test=test3", url);
}
示例9: ShouldAccumulateFullTriangle
public void ShouldAccumulateFullTriangle()
{
var expectedValues = new[] { "ProductA",
"45.2", "110", "110", "147",
"50", "125", "150",
"55", "140",
"100" };
var triangle = new ClaimTriangle("ProductA", _collector);
triangle[1990][1990] = 45.2;
triangle[1990][1991] = 64.8;
triangle[1990][1993] = 37;
triangle[1991][1991] = 50;
triangle[1991][1992] = 75;
triangle[1991][1993] = 25;
triangle[1992][1992] = 55;
triangle[1992][1993] = 85;
triangle[1993][1993] = 100;
var actualValues = triangle.Accumulate().Flatten(new TriangleDimensions { OriginYear = 1990, DevelopmentYears = 4 });
for (int i = 0; i < actualValues.Length; i++)
{
Assert.Equal(expectedValues[i], actualValues[i]);
}
}
示例10: BugfixingLeaderSorted_Test
public void BugfixingLeaderSorted_Test()
{
//var numbers = new int[] {1, 1, 1, 1, 50};
//var numbers = new int[] {2, 2, 2, 2, 2, 3, 4, 4, 4, 6};
var numbers = new[] {2, 2, 2, 2, 2, 3, 4, 4, 4};
int result = Kata.Solution(numbers);
}
示例11: TestValidSources
public void TestValidSources()
{
// Arrange
string[] testValues = new[] { "http://bing.com", "http://microsoft.com", "https://paypal.com", "http://library" };
TestValues(testValues, true);
}
示例12: TestInvalidSources
public void TestInvalidSources()
{
// Arrange
string[] testValues = new[] { null, "", "link", "c:\\dir", "\\username\folder", "127.0.0.1", "localhost", "crash;\\_andBurn", "ftp://bing.com", "gopher://kill.it", "http://" };
TestValues(testValues, false);
}
示例13: Y2015_Day13_GetMaximumTotalChangeInHappiness
public static void Y2015_Day13_GetMaximumTotalChangeInHappiness()
{
// Arrange
string[] potentialHappiness = new[]
{
"Alice would gain 54 happiness units by sitting next to Bob.",
"Alice would lose 79 happiness units by sitting next to Carol.",
"Alice would lose 2 happiness units by sitting next to David.",
"Bob would gain 83 happiness units by sitting next to Alice.",
"Bob would lose 7 happiness units by sitting next to Carol.",
"Bob would lose 63 happiness units by sitting next to David.",
"Carol would lose 62 happiness units by sitting next to Alice.",
"Carol would gain 60 happiness units by sitting next to Bob.",
"Carol would gain 55 happiness units by sitting next to David.",
"David would gain 46 happiness units by sitting next to Alice.",
"David would lose 7 happiness units by sitting next to Bob.",
"David would gain 41 happiness units by sitting next to Carol.",
};
// Act
int actual = Day13.GetMaximumTotalChangeInHappiness(potentialHappiness);
// Assert
Assert.Equal(330, actual);
}
示例14: Should_be_able_to_convert_to_json
public void Should_be_able_to_convert_to_json()
{
var obj = new { foo = "bar" };
var json = obj.ToJson();
Assert.NotEqual(string.Empty, json);
}
示例15: NextItemTest
public void NextItemTest()
{
Random rnd = new Random();
int[] array = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int item = rnd.NextItem(array);
Assert.Contains(item, array);
}