CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
TestResults.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="TestResults.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Static, dictionary-style container for test results</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using System.Threading;
12
13namespace Csla.Test
14{
15
20 public class TestResults
21 {
22 private static AsyncLocal<Dictionary<string, string>> _testResults = new AsyncLocal<Dictionary<string, string>>();
23
29 public static void Add(string key, string value)
30 {
31 _testResults.Value.Add(key, value);
32 }
33
39 public static void AddOrOverwrite(string key, string value)
40 {
41 _testResults.Value[key] = value;
42 }
43
49 public static string GetResult(string key)
50 {
51 if (!_testResults.Value.ContainsKey(key)) return string.Empty;
52
53 return _testResults.Value[key];
54 }
55
61 public static bool ContainsResult(string key)
62 {
63 return _testResults.Value.ContainsKey(key);
64 }
65
69 public static void Reinitialise()
70 {
71 if (_testResults.Value is null) _testResults.Value = new Dictionary<string, string>();
72 _testResults.Value.Clear();
73 }
74
75 }
76}
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
Definition: TestResults.cs:69
static string GetResult(string key)
Get a result of an operation from the underlying results dictionary
Definition: TestResults.cs:49
static void AddOrOverwrite(string key, string value)
Overwrite an item in the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:39
static bool ContainsResult(string key)
Get the existence of a result of an operation from the underlying results dictionary
Definition: TestResults.cs:61
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:29