public DisposableClassWithDictionaryStringString() { _myDictionary = new Dictionary <string, string> { { "A Key", "A Value" } }; TestHelp.DoNothing(_myDictionary); }
public static void ThisTestClassInitialize(TestContext context) { // quieting intermittent code analysis warning TestHelp.DoNothing(context); target = new NonRecursiveLock(); }
protected override void ArrangeMethod() { traceLines = new List <string>(); memoryStream = DisposableHelper.SafeCreate( () => { var rv = DisposableHelper.SafeCreate(() => new MemoryStream()); rv.Capacity = 1024 * 1024; rv.Position = 0; return(rv); }); var streamWriter = new StreamWriter(memoryStream) { AutoFlush = true }; memoryListener = new TextWriterTraceListener(streamWriter); Trace.Listeners.Add(memoryListener); source = new EventSource(); removedInstanceSink = new EventSink(source); removedInstanceId = removedInstanceSink.Id; TestHelp.DoNothing(removedInstanceSink); keptInstanceSink = new EventSink(source); keptInstanceId = keptInstanceSink.Id; TestHelp.DoNothing(keptInstanceSink); }
public static void PerformDbServiceActions(Action <DbService, LajetContext> ActAndTest) { using var db = TestHelp.CreateInMemLajetContext(); db.Database.EnsureDeletedAsync(); db.Database.EnsureCreatedAsync(); var service = new DbService(db); ActAndTest.Invoke(service, db); }
public void It_should_throw_on_WaitingWriteCount() { object ignored = null; Action throwingAction = () => ignored = TargetDiagnostic.WaitingWriteCount; var e = throwingAction.Should().Throw <ObjectDisposedException>(); e.WithMessage("*Cannot access a disposed object.*"); e.WithMessage("*NonRecursiveLock*"); TestHelp.DoNothing(ignored); }
public static void AssemblyInitialize(TestContext context) { // quieting intermittent code analysis warning TestHelp.DoNothing(context); // acquire assemblies under test var assemblies = ImmutableHashSet <Assembly> .Empty.ToBuilder(); // Landorphan.Common assemblies.Add(typeof(DisposableHelper).Assembly); AssembliesUnderTest = assemblies.ToImmutable(); }
public void Setsync() { Monitor <int?> m = new Monitor <int?>("a", null); bool[] flag = new bool[2000]; Thread t = new Thread(new ThreadStart(delegate() { for (int i = 0; i < 1000; i++) { int?x = m.Set(i); flag[x.GetValueOrDefault()] = true; } })); Thread t1 = TestHelp.Delay(1000, t); Thread t2 = TestHelp.Delay(1000, new Thread(new ThreadStart(delegate() { for (int i = 1000; i < 2000; i++) { int?x = m.Set(i); flag[x.GetValueOrDefault()] = true; } } ))); t1.Start(); t2.Start(); t1.Join(); t2.Join(); int?x1 = m.Set(null); flag[x1.GetValueOrDefault()] = true; foreach (bool b in flag) { Assert.IsTrue(b); } }
public void waitUntilNotEqAndSet4() { Monitor <int?> m = new Monitor <int?>("a", null); Thread t = TestHelp.delayAndStart(200, new Thread(new ThreadStart(delegate() { m.Set(1); }))); long t0 = HPTimer.Now(); m.WaitUntilNotEqAndSet(null, 2); double t1 = (HPTimer.Now() - t0) / 1000000.0; TestHelp.AssertRelError(200, t1, REL_ERROR); t.Join(); }
public void waitUntilEqAndSet4() { Monitor <int?> m = new Monitor <int?>("a", null); Thread t = TestHelp.delayAndStart(200, new Thread(new ThreadStart(delegate() { m.Set(1); }))); long t0 = HPTimer.Now(); m.WaitUntilEqAndSet(1, 2); double t1 = (HPTimer.Now() - t0) / 1000000.0; // TODO is there a better way for choosing relative error? TestHelp.AssertRelError(200, t1, REL_ERROR); t.Join(); }
public void HelpTest() { TestPage testPage = new TestPage(); TestIPropertyPageSite testSite = new TestIPropertyPageSite(); TestHelp testHelp = new TestHelp(); testSite.ServiceObjects.Add(typeof(Microsoft.VisualStudio.VSHelp.Help), testHelp); testPage.SetPageSite(testSite); testPage.Help(""); Assert.AreEqual("TestPageHelp", testHelp.KeywordsDisplayed[0]); }
public void SetFlatField(IDisposable value) { flatField = value; TestHelp.DoNothing(flatField); }
public void SetAnotherField(IDisposable value) { anotherField = value; TestHelp.DoNothing(anotherField); }