本文整理汇总了C#中Example类的典型用法代码示例。如果您正苦于以下问题:C# Example类的具体用法?C# Example怎么用?C# Example使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Example类属于命名空间,在下文中一共展示了Example类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThenCanFormatScenarioOutlineWithMissingNameCorrectly
public void ThenCanFormatScenarioOutlineWithMissingNameCorrectly()
{
var table = new Table
{
HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
DataRows =
new List<TableRow>(new[]
{
new TableRow("1", "2", "3", "4"),
new TableRow("5", "6", "7", "8")
})
};
var example = new Example { Name = "Some examples", Description = "An example", TableArgument = table };
var examples = new List<Example>();
examples.Add(example);
var scenarioOutline = new ScenarioOutline
{
Description = "We need to make sure that scenario outlines work properly",
Examples = examples
};
var htmlScenarioOutlineFormatter = Container.Resolve<HtmlScenarioOutlineFormatter>();
var output = htmlScenarioOutlineFormatter.Format(scenarioOutline, 0);
Check.That(output).ContainsGherkinScenario();
Check.That(output).ContainsGherkinTable();
}
示例2: ThenCanFormatScenarioOutlineWithMissingDescriptionCorrectly
public void ThenCanFormatScenarioOutlineWithMissingDescriptionCorrectly()
{
var table = new Table
{
HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
DataRows =
new List<TableRow>(new[]
{
new TableRow("1", "2", "3", "4"),
new TableRow("5", "6", "7", "8")
})
};
var example = new Example { Name = "Some examples", Description = "An example", TableArgument = table };
var examples = new List<Example>();
examples.Add(example);
var scenarioOutline = new ScenarioOutline
{
Name = "Testing a scenario outline",
Examples = examples
};
var htmlScenarioOutlineFormatter = Container.Resolve<HtmlScenarioOutlineFormatter>();
var output = htmlScenarioOutlineFormatter.Format(scenarioOutline, 0);
output.ShouldContainGherkinScenario();
output.ShouldContainGherkinTable();
}
示例3: QueryingUsingObjects
public void QueryingUsingObjects()
{
using (var store = NewDocumentStore())
{
store.Conventions.CustomizeJsonSerializer += serializer =>
{
serializer.TypeNameHandling = TypeNameHandling.All;
};
using (var session = store.OpenSession())
{
var obj = new Outer { Examples = new List<IExample>() { new Example { Provider = "Test", Id = "Abc" } } };
session.Store(obj);
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var ex = new Example { Provider = "Test", Id = "Abc" };
var arr = session.Query<Outer>().Customize(c => c.WaitForNonStaleResults())
.Where(o => o.Examples.Any(e => e == ex))
.ToArray();
WaitForUserToContinueTheTest(store);
Assert.Equal(1, arr.Length);
}
}
}
示例4: Main
public static void Main()
{
Example e = new Example(1, 2.5); // use constructor
// this creates the first Example object with reference e
Console.WriteLine("e.n = {0}", e.GetN()); // prints 1
Console.WriteLine("e.d = {0}", e.GetD()); // prints 2.5
Console.WriteLine(e); // prints Example: n = 1, d = 2.5
e.SetN(25);
e.SetD(3.14159);
Console.WriteLine("e.n = {0}", e.GetN()); // prints 25
Console.WriteLine("e.d = {0}", e.GetD()); // prints 3.14159
Console.WriteLine(e); // prints Example: n = 25, d = 3.14159
Example e2 = new Example(3, 10.5);
// this creates the second Example object with reference e2
Console.WriteLine(e2); // prints Example: n = 3, d = 10.5
e = e2; // now both e and e2 reference the second object
// the first Example object is now no longer referenced
// and its memory can be reclaimed at runtime if necessary
Console.WriteLine(e); // prints Example: n = 3, d = 10.5
e2.SetN(77); // symbolism uses e2, not e
Console.WriteLine(e2); // prints Example: n = 77, d = 0
Console.WriteLine(e); // prints Example: n = 77, d = 0
// but e is the same object - so its fields are changed
}
示例5: Should_build_string_step
public void Should_build_string_step(string stringStep)
{
var step = new StringStep(stringStep, "whatever");
var example = new Example(new ExampleColumns(new[] { new ExampleColumn("param"), }), new Dictionary<string, string> { { "param", "12" } });
var newStep = step.BuildStep(example);
Assert.That(newStep.Step, Is.EqualTo("Given a 12"));
}
示例6: setupWithDatabase
protected override void setupWithDatabase(Example.ExampleContext db)
{
base.setupWithDatabase(db);
m = db.ModelsWithDynamicProxies.Create();
db.ModelsWithDynamicProxies.Add(m);
save();
}
示例7: GetParametersForStep
public object[] GetParametersForStep(StringStep stringStep, Example example)
{
var action = _actionCatalog.GetAction(stringStep);
Func<string, string> getValues = i => example.ColumnValues[i];
var paramNames = action.ParameterInfo.Select(a => a.Name).ToList();
return GetParametersForStep(action, paramNames, getValues);
}
示例8: ShouldBeSerializable
public void ShouldBeSerializable()
{
var e = new Example(new ExampleColumns(new[] { "a" }), new Dictionary<string, string> { { "a", "a" } });
var ser = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using (var ms = new MemoryStream())
ser.Serialize(ms, e);
Assert.IsTrue(true, "Serialization succeded");
}
示例9: Create
static Example Create(AbstractFactory factory)
{
Example example = new Example();
example.product1 = factory.CreateProduct1(10);
example.product2 = factory.CreateProduct2(20f);
example.product3 = factory.CreateProduct3("thirty");
return example;
}
示例10: pending_example
public void pending_example()
{
var it = new Example("Bar", Spec.Pending, new ActiveExampleContainer("Foo", null, null), null);
it.Execute(Listener);
Listener.Calls[0].ShouldStartWith("Pending - Foo\r\nBar");
}
示例11: notifies_listener_on_success
public void notifies_listener_on_success()
{
var it = new Example("Bar", () => Assert.IsTrue(true), new ActiveExampleContainer("Foo", null, null), null);
it.Execute(Listener);
Listener.Calls[0].ShouldBe("Success - Foo\r\nBar");
}
示例12: notifies_listener_on_failure
public void notifies_listener_on_failure()
{
var it = new Example("Bar", () => Assert.IsTrue(false), new ActiveExampleContainer("Foo", null, null), null);
it.Execute(Listener);
Listener.Calls[0].ShouldBe("Failed - Foo\r\nBar - AssertionException");
}
示例13: handles_predicate_expression_success
public void handles_predicate_expression_success()
{
var it = new Example("Bar", () => true, new ActiveExampleContainer("Foo", null, null), null);
it.Execute(Listener);
Listener.Calls[0].ShouldBe("Success - Foo\r\nBar");
}
示例14: Write
public string Write( Example e, int level = 1 )
{
var failure = e.ExampleLevelException == null ? "" : " - FAILED - {0}".With( e.ExampleLevelException.CleanMessage() );
var whiteSpace = Environment.NewLine + indent.Times( level );
return e.Pending ? whiteSpace + e.Spec + " - PENDING" : whiteSpace + e.Spec + failure;
}
示例15: ExecuteExample
private ExampleResult ExecuteExample(ExampleGroup exampleGroup, Example example)
{
stratergyOption.Into(stratergy => stratergy.ExecuteAction(exampleGroup.BeforeEach));
var result = stratergyOption.Into(stratergy => stratergy.ExecuteActionWithResult(example.Action).ToExampleResult(example)).Or(example.ToExampleResult()).First();
stratergyOption.Into(stratergy => stratergy.ExecuteAction(exampleGroup.AfterEach));
return result;
}