Format:
Recent snippets matching tags of Test
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/ //#pragma comment(linker,"/STACK:33554432") /*32Mb*/ #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<numeric> #include<sstream> #include<cstdio> #include<cstdlib> #include<cmath> #include<memory>
12 Views
no comments
public static class UnityContainerExtensions { public static void AssertMappingsAreValid(this IUnityContainer container) { foreach (var registration in container.Registrations) { container.Resolve(registration.RegisteredType, registration.Name); } } }
90 Views
no comments
using System; using System.Data; using System.Data.SqlClient; class Program { static void Main() { string connectionString = "Data Source=(local);Initial Catalog=Northwind;"
43 Views
no comments
[Test, ExpectedException(typeof(ArgumentNullException))] private void MyTest() { /// }
156 Views
no comments
#include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; }
107 Views
no comments
[Test] [ThreadedRepeat(5)] public void Should_handle_multithreaded_access() { Assert.IsNotEmpty(MyClass.GetExpensiveString()); }
166 Views
no comments
// This example reads data from an Embedded Resource // called Data.bin within the same namespace as the test fixture. [Test] public void ShoppingCartTotalWithSingleItem( [BinaryData(ResourcePath = "Data.bin")] byte[] data) { // Code logic here... }
161 Views
no comments
[Test] public void MyTest( [Column(1, 2, 3)] int x, [Column("a", "b")] string y, [Column(0.1, 0.2)] double z) { // This test will run 3 * 2 * 2 = 12 times with all combinations of // the values specified in the column for each parameter. This test // is combinatorial because the values are assigned to each parameter // separately.
116 Views
no comments
[Comparer] public static int Compare(Foo x, Foo y) { return /* Insert comparison logic here... */ } [Converter] public static Pen KnownColorToPen(KnownColor knownColor) { return new Pen(Color.FromKnownColor(knownColor)); }
133 Views
no comments
[Test] [CsvData(ResourcePath = "Data.csv")] public void ShoppingCartTotalWithSingleItem(string item, decimal unitPrice, decimal quantity) { ShoppingCart shoppingCart = new ShoppingCart(); shoppingCart.Add(item, unitprice, quantity); Assert.AreEqual(unitPrice * quantity, shoppingCart.TotalCost); }
124 Views
no comments
[TestFixture] public class MyTestFixture { [Test] [Impersonate(UserName = "Julius Caesar", Password = "VeniVidiVici")] public void MyTest() { // Some test logic here... } }
178 Views
no comments
[TestFixture] public class MyTestFixture { [Test] [MultipleCulture("en-US", "en-GB")] public void CheckCurrencySymbol() { Assert.AreEqual("$4.50", String.Format("{0:C}", 4.5d); } }
155 Views
no comments
// Specifies that a test can be run in // parallel with other parallelizable tests public class Fixture { // may run in parallel with test 2 [Parallelizable] public void Test1() { ... } // may run in parallel with test 1
143 Views
no comments
[Header("Parameter1", "Parameter2")] [Row(1, "a")] [Row(2, "b")] public class Fixture { [Parameter] public int Parameter1; [Parameter] public string Parameter2 { get; set; }
119 Views
no comments
public class MyPrincipalAttribute : PrincipalAttribute { protected override IPrincipal CreatePrincipal() { // Create or retrieve the principal... } } [TestFixture] public class MyTestFixture
112 Views
no comments
[Test] public void MyTestMethod([RandomNumbers(Minimum = 0, Maximum = 10, Count = 3)] decimal value) { // This test will run 3 times. It generates at each iteration // a decimal number between 0 and 10. }
108 Views
no comments
[Test] [Row(1, "a", 0.1)] [Row(2, "b", 0.2)] public void MyTest(int x, string y, double z) { // This test will run twice. Once with x = 1, y = "a", and z = 0.1 // then again with x = 2, y = "b", and z = 0.2. }
114 Views
no comments
[Test] public void MyTestMethod2( [SequentialNumbers(Start = 0, End = 10, Count = 5)] decimal value) { // This test will run 5 times with the values 0, 2.5, 5, 7.5, and 10. }
147 Views
no comments
[TestFixture] public class MyTestFixture { [Test] public void MyTestMethod([RandomStrings(Count = 3, Pattern = @"[A-Z]{5,8}")] string text) { // This test will run 3 times. It generates at each iteration // a random string containing 5 to 8 uppercase alphabetic characters. } }
152 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
