Beispiel #1
0
        public void TraceInfoErrorsAreReportedForInvalidConnectionString([DataSources(false)] string context)
        {
            var events   = GetEnumValues((TraceInfoStep s) => default(TraceInfo));
            var counters = GetEnumValues((TraceInfoStep s) => 0);

            using (var db0 = (TestDataConnection)GetDataContext(context))
                using (var db = new DataContext(db0.DataProvider.Name, "BAD"))
                {
                    db.OnTraceConnection = e =>
                    {
                        events[e.TraceInfoStep] = e;
                        counters[e.TraceInfoStep]++;
                    };

                    NUnitAssert.ThrowsAny(() => db.GetTable <Child>().ToList(), typeof(ArgumentException), typeof(InvalidOperationException));

                    // steps called once
                    Assert.AreEqual(1, counters[TraceInfoStep.Error]);
                    Assert.AreEqual(1, counters[TraceInfoStep.Completed]);

                    // steps never called
                    Assert.AreEqual(0, counters[TraceInfoStep.BeforeExecute]);
                    Assert.AreEqual(0, counters[TraceInfoStep.AfterExecute]);
                    Assert.AreEqual(0, counters[TraceInfoStep.MapperCreated]);
                }
        }
Beispiel #2
0
 public void ProviderConnectionStringConstructorTest2([DataSources(false)] string context)
 {
     using (var db = (TestDataConnection)GetDataContext(context))
         using (var db1 = new DataContext(db.DataProvider.Name, "BAD"))
         {
             NUnitAssert.ThrowsAny(() => db1.GetTable <Child>().ToList(), typeof(ArgumentException), typeof(InvalidOperationException));
         }
 }