public ApiController(ILogger <ApiController> logger, IConfiguration config, IMemoryCache memoryCache) { this.logger = logger; this.config = config; this.memoryCache = memoryCache; this.testTypes = new TestTypes(); }
private void RemoveTestProc() { if (SelectedTestType != null) { TestTypes.Remove(SelectedTestType); } }
/// <summary> /// create subtree for parentNode according to the testPriority, testType and testFilter /// </summary> private void CreateTestPrioritySubtree(TestPriorities testPriority, TestTypes testType, TreeNode parentNode, AutomationTestsFilter testFilter) { //create node for the priority TreeNode priorityNode = new TreeNode(GetPriorityName(testPriority)); parentNode.Nodes.Add(priorityNode); TreeNode currentRootNode = priorityNode; //create filter for the priority AndFilter priorityFilter = new AndFilter(new TestFilterPriority(testPriority), testFilter); //for all filtered available automation tests lets create tree node foreach (AutomationTest test in AutomationTestCollection.Filter(priorityFilter)) { //lets make copy ot the test with only TestType and TestPriority belonging to this //branch AutomationTest testClone = new AutomationTest(test, testPriority, testType); TreeNode testNode = new TreeNode(testClone.Name); testNode.Tag = testClone; currentRootNode.Nodes.Add(testNode); } //if no child currentTestTypeRootNode was added then remove priority currentTestTypeRootNode if (currentRootNode.Nodes.Count == 0) { currentRootNode.Remove(); } }
private static void Fill(List <int> MyItemsToSort, int testT) { MyItemsToSort.Clear(); if ((TestTypes)testT == TestTypes.Random) { FillRandomInts(MyItemsToSort); } else { bool Ascending = true; bool constantNums = false; TestTypes typeOfTest = (TestTypes)testT; switch (typeOfTest) { case TestTypes.Ordered: //Nums go up from 1 break; case TestTypes.Reversed: //nums go down to 1 Ascending = false; break; case TestTypes.Constant: //All nums the same constantNums = true; break; } FillInts(MyItemsToSort, constantNums, Ascending); } }
public WorkItem(INamedTypeSymbol testClass, INamedTypeSymbol classUnderTest, TestTypes testTypes, TestFramework testFramework) { TestClass = testClass ?? throw new ArgumentNullException(nameof(testClass)); ClassUnderTest = classUnderTest ?? throw new ArgumentNullException(nameof(classUnderTest)); TestTypes = testTypes; TestFramework = testFramework; }
/// <summary> /// This method extracts test type of the test. /// </summary> private void ExtractTestType() { //we have to use hard-coded names because there is no other way how to get the type TestTypes testType = TestTypes.None; if (this.Method.ReflectedType.FullName.EndsWith(".AutomationElementTests")) { testType |= TestTypes.AutomationElementTest; } if (this.Method.ReflectedType.FullName.Contains(".Tests.Patterns.")) { testType |= TestTypes.PatternTest; } else if (this.Method.ReflectedType.FullName.Contains(".Tests.Controls.")) { testType |= TestTypes.ControlTest; } //else if (this.Method.ReflectedType.FullName.Contains(".Tests.Scenarios.")) // testType |= TestTypes.ScenarioTest; else if (this.Method.ReflectedType.FullName.EndsWith(".Tests.ControlObject")) { testType |= TestTypes.ControlTest; } //else // //in debug mode we will notidy user about notsupported test // //in release mode we will ignore this test // Debug.Fail("not supported TestType: " + this.Method.ReflectedType.FullName); this._testType = testType; }
/// <summary> /// initializes new instance with the testPriority and testType /// </summary> public AutomationTest(AutomationTest originalTest, TestPriorities testPriority, TestTypes testType) { this.TestCaseAttribute = originalTest.TestCaseAttribute; this.Method = originalTest.Method; this._testPriority = testPriority; this._testType = testType; }
internal TestCaseDescriptor(string suite, string name, string fullyQualifiedName, string displayName, TestTypes testType) { Suite = suite; Name = name; DisplayName = displayName; FullyQualifiedName = fullyQualifiedName; TestType = testType; }
public void CanConvertEnumIntoFriendlyString(TestTypes value, string expected) { // Arrange/Act var actual = value.ToFriendlyString(); // Assert Assert.That(actual, Is.Not.Null.And.EqualTo(expected)); }
public void CanConvertEnumIntoFriendlyString(TestTypes value, string expected) { // Arrange/Act var actual = value.ToFriendlyString(); // Assert Assert.NotNull(actual); Assert.Equal(expected, actual); }
private void AddNewTestProc() { if (TestTypes.Any(c => c.Name == TestTypeModel.Name)) { return; } TestTypes.Add(TestTypeModel); TestTypeModel = new TestType(); }
public void StorageScuMoveOriginatorTest() { int port = 2112; _serverHandlerList.Clear(); /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); string moveOriginatorAe = "ORIGINATOR"; ushort moveOriginatorId = 999; StorageScu scu = SetupScu(moveOriginatorAe, moveOriginatorId); IList <DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; scu.AddStorageInstance(new StorageInstance(file)); } scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning); var handler = CollectionUtils.FirstElement(_serverHandlerList); var serverHandler = handler as ServerHandler; Assert.NotNull(serverHandler); foreach (var message in serverHandler.MessagesReceived) { Assert.AreEqual(message.MoveOriginatorApplicationEntityTitle, moveOriginatorAe); Assert.AreEqual(message.MoveOriginatorMessageId, moveOriginatorId); } // StopListening DicomServer.StopListening(serverParameters); }
public async Task <IActionResult> Create(TestTypes testTypes) { if (ModelState.IsValid) { // _db.ProductTypes.Add(productTypes); _db.Add(testTypes); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(testTypes)); }
public void RejectTests() { int port = 2112; /* Setup the Server */ ServerAssociationParameters serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.AssociationReject; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ ClientAssociationParameters clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new System.Net.IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ ClientHandler handler = new ClientHandler(this, TestTypes.AssociationReject); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); _serverType = TestTypes.AssociationReject; /* Setup the client */ clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new System.Net.IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.Jpeg2000ImageCompressionLosslessOnly); /* Open the association */ ClientHandler clientHandler = new ClientHandler(this, TestTypes.AssociationReject); client = DicomClient.Connect(clientParameters, clientHandler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
private void SetGraph() { if (GradingSystem == null) { return; } foreach (var g in GradingSystem.TestTypes) { TestTypes.Add(new TestForGraph() { Test = Tests.Where(c => c.TestType == g).ToList(), Name = g.Name }); } }
// returns true if an intformational option // was printed static bool PrintInformationalOptions (TestTypes setType) { // only print help if it is specified if (GetOption ("help").Set) { PrintUsage (true); return true; } // list tests if (GetOption ("list").Set) { PrintTestList (setType, false); return true; } else if (GetOption ("listdesc").Set) { PrintTestList (setType, true); return true; } // list valid sets if (GetOption ("setlist").Set) { Console.WriteLine ("Sets of tests:"); foreach (TestTypeOption opt in testTypeOptions) { Console.WriteLine ("- " + opt.Name); } return true; } #if !WHIDBEY if (GetOption ("languagename").Set) { // lang is not supported in non-Whidbey environements ErrorWriteLine ("The /languagename (short: /lang) option was not compiled into this assembly, "); ErrorWriteLine ("and is not supported. Did you compile with /d:WHIDBEY?"); return true; } #endif // check for required options if ((!GetOption ("codedomprovider").Set || !GetOption ("languagename").Set) && !GetOption ("testcaselib").Set) { PrintUsage (false); ErrorWriteLine (); ErrorWriteLine ("Missing required options."); return true; } return false; }
public static void TestByName(TestTypes testType) { if (testType == TestTypes.battleRoyale) { Test.Fight.BattleRoyaleTest(unit, unitMount); } else if (testType == TestTypes.statisticTest) { Test.Fight.StatisticTest(unit, unitMount, enemy, enemyMount); } else { Test.Fight.FullTest(unit, unitMount, enemy, enemyMount); } }
public async Task <IActionResult> Edit(int id, int code, int specialtag, TestTypes testTypes) { if (id != testTypes.Id) { return(NotFound()); } if (ModelState.IsValid) { // _db.ProductTypes.Add(productTypes); _db.Update(testTypes); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(testTypes)); }
public void ScuAbortTest() { int port = 2112; /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); StorageScu scu = SetupScu(); IList <DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; scu.AddStorageInstance(new StorageInstance(file)); } scu.ImageStoreCompleted += delegate(object o, StorageInstance instance) { // Test abort scu.Abort(); }; scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NetworkError); // StopListening DicomServer.StopListening(serverParameters); }
public List <string> GetOfType(Family[] families) { if (families.Length == 0) { return(TestTypes.GetAll()); } if (families.Length > 4) { throw new ArgumentException("There cannot be more than 4 families to pick!"); } var set = new List <string>(); families.ToList().ForEach(x => set.AddRange(GetFamily(x))); return(set); }
private void testTypesMenuToolStrip_Click(object sender, EventArgs e) { ToolStripMenuItem senderMenu = (ToolStripMenuItem)sender; Debug.Assert(senderMenu.Tag is TestTypes, "MainWindow design is broken!"); TestTypes testType = (TestTypes)senderMenu.Tag; TestTypes newValue = _automationTests.Types; if (senderMenu.Checked) { newValue |= testType; //add flag } else { newValue &= ~testType; //remove flag } _automationTests.Types = newValue; }
public void ScuAbortTest() { int port = 2112; /* Setup the Server */ ServerAssociationParameters serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); StorageScu scu = SetupScu(); IList<DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { DicomFile file = new DicomFile("test",new DicomAttributeCollection(),collection ); file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian; file.MediaStorageSopClassUid = SopClass.MrImageStorage.Uid; file.MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString(); scu.AddStorageInstance(new StorageInstance(file)); } scu.ImageStoreCompleted += delegate(object o, StorageInstance instance) { // Test abort scu.Abort(); }; scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NetworkError); // StopListening DicomServer.StopListening(serverParameters); }
public List <TestTypes> GetAllTestType() { List <TestTypes> allTestTypes = new List <TestTypes>(); Query = "SELECT * FROM TestType ORDER BY testType"; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); while (Reader.Read()) { TestTypes testTypes = new TestTypes(); string testType = Reader["testType"].ToString(); testTypes.TestTypeName = testType; testTypes.Index = Convert.ToInt32(Reader["ID"]); allTestTypes.Add(testTypes); } Reader.Close(); Connection.Close(); return(allTestTypes); }
private List <string> GetFamily(Family family) { switch (family) { case Family.ANAEROBIC: return(TestTypes.GetAnaerobic()); case Family.GRAM_MINUS: return(TestTypes.GetGramMinus()); case Family.GRAM_PLUS: return(TestTypes.GetGramPlus()); case Family.FUNGI: return(TestTypes.GetFungi()); default: throw new ArgumentException("Unknown family type!"); } }
// Overrides everything with the sum of its parts int FixBitmask(int mask) { if (mask == -1) // If set to everything { int typeCount = TestTypes.GetTypeStringList().Length; // Get type count int value = 0; // Create an integer to track value for (int i = 0; i < typeCount; i++) // Iterate types { int checkBit = mask & (int)Mathf.Pow(2, i); if (checkBit != 0) { value |= (int)Mathf.Pow(2, i); } } return(value); // Set value to the sum } else { return(mask); } }
public double GetTestTypeValue(string testtype) { var types = testtype.Split(','); var values = new List <double>(); foreach (var type in types) { var trimmedType = type.Trim(); var value = TestTypes.ContainsKey(trimmedType) ? TestTypes[trimmedType] : 1.0; values.Add(value); } if (values.Count > 0) { return(values.Max()); } else { return(1.0); } }
/// <summary> /// returns user friendly name for testType /// </summary> private string GetTestTypeName(TestTypes testType) { string name; switch (testType) { case TestTypes.AutomationElementTest: name = "Automation Element Tests"; break; case TestTypes.PatternTest: name = "Pattern Tests"; break; case TestTypes.ControlTest: name = "Control Tests"; break; //case TestTypes.ScenarioTest: name = "Scenario Tests"; break; default: { Debug.Fail("unexpected TestTypes value"); name = Enum.GetName(typeof(TestTypes), testType); } break; } return(name); }
public List <TestTypes> GetAllTestType() { List <TestTypes> testTypes = new List <TestTypes>(); string query = "SELECT *FROM TestTypes"; Command.CommandText = query; Connection.Open(); SqlDataReader reader = Command.ExecuteReader(); if (reader.HasRows) { int count = 0; while (reader.Read()) { TestTypes aTestType = new TestTypes(); aTestType.Sl = Convert.ToInt32(reader["Id"]); aTestType.TestType = reader["Name"].ToString(); testTypes.Add(aTestType); } Connection.Close(); } return(testTypes); }
public void ServerTest() { const int port = 2112; /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.SendMR; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ var clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ var handler = new ClientHandler(this, TestTypes.SendMR); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
public ClientHandler(AbstractTest test, TestTypes type) { _test = test; _type = type; }
public void ServerTest() { int port = 2112; /* Setup the Server */ ServerAssociationParameters serverParameters = new ServerAssociationParameters("AssocTestServer",new IPEndPoint(IPAddress.Any,port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.SendMR; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ ClientAssociationParameters clientParameters = new ClientAssociationParameters("AssocTestClient","AssocTestServer", new System.Net.IPEndPoint(IPAddress.Loopback,port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ ClientHandler handler = new ClientHandler(this,TestTypes.SendMR); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
public ServerHandler(AbstractTest test, TestTypes type) { _test = test; _type = type; }
public TestFilterType(TestTypes testType) { this._testType = testType; }
/// <summary> /// returns user friendly name for testType /// </summary> private string GetTestTypeName(TestTypes testType) { string name; switch (testType) { case TestTypes.AutomationElementTest: name = "Automation Element Tests"; break; case TestTypes.PatternTest: name = "Pattern Tests"; break; case TestTypes.ControlTest: name = "Control Tests"; break; //case TestTypes.ScenarioTest: name = "Scenario Tests"; break; default: { Debug.Fail("unexpected TestTypes value"); name = Enum.GetName(typeof(TestTypes), testType); } break; } return name; }
public void StorageScuFromDisk() { int port = 2112; _serverHandlerList.Clear(); /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); StorageScu scu = SetupScu(); IList<DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; string instancePath = file.MediaStorageSopInstanceUid + ".dcm"; file.Save(instancePath); var instance = new StorageInstance(instancePath) { SopClass = file.SopClass, TransferSyntax = file.TransferSyntax, SopInstanceUid = file.MediaStorageSopClassUid, PatientId = file.DataSet[DicomTags.PatientId].GetString(0, string.Empty), PatientsName = file.DataSet[DicomTags.PatientsName].GetString(0, string.Empty), StudyInstanceUid = file.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty) }; scu.AddStorageInstance(instance); } scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning); var handler = CollectionUtils.FirstElement(_serverHandlerList); var serverHandler = handler as ServerHandler; Assert.NotNull(serverHandler); foreach (var message in serverHandler.MessagesReceived) { foreach (var file in list) { if (message.AffectedSopInstanceUid.Equals(file[DicomTags.SopInstanceUid].ToString())) { Assert.IsTrue(message.DataSet.Equals(file)); } } } // StopListening DicomServer.StopListening(serverParameters); }
public TestTypeOption (string optionName, TestTypes types, Version runtimeVersion) { if (optionName == null) throw new ArgumentNullException ("optionName"); if (runtimeVersion == null) throw new ArgumentNullException ("runtimeVersion"); this.optionName = optionName; this.types = types; this.runtimeVersion = runtimeVersion; }
public void RejectTests() { const int port = 2112; /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.AssociationReject; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ var clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ var handler = new ClientHandler(this, TestTypes.AssociationReject); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); _serverType = TestTypes.AssociationReject; /* Setup the client */ clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.Jpeg2000ImageCompressionLosslessOnly); /* Open the association */ var clientHandler = new ClientHandler(this, TestTypes.AssociationReject); client = DicomClient.Connect(clientParameters, clientHandler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
public ServerHandler(AbstractTest test, TestTypes type) { _test = test; _type = type; MessagesReceived = new List<DicomMessage>(); }
/// <summary> /// this method creates automation tests subtree for particular test type /// </summary> /// <param name="testType"></param> /// <param name="testFilter">filter to be applied on all available automation tests collection</param> private void CreateTestTypeNodeSubtree(TestTypes testType, AutomationTestsFilter testFilter) { //create root currentTestTypeRootNode for the currentTestTypeRootNode type TreeNode currentTestTypeRootNode = new TreeNode(GetTestTypeName(testType)); _testsTreeView.Nodes[0].Nodes.Add(currentTestTypeRootNode); if (testType == TestTypes.ControlTest) { //if ControlTest test type is required then let's get automation ControlType //for the selected automation element. If we are showing all tests, not only for selected //elements then let's get all automation element ControlTypes. //for all grabbed ControlTypes let's create subtree with tests ControlType[] controlTypes; if (this._scope == TestsScope.SelectedElementTests) { try { //get control type if selected automation element controlTypes = new ControlType[] { this._selectedElement.Current.ControlType }; } catch (ElementNotAvailableException) { //if there are problems with the elements then ignore it controlTypes = new ControlType[] { }; } } else { // let's get all automation technology ControlTypes controlTypes = AutomationHelper.GetAllAutomationControlTypes(); } //fore each control type, let's create subtree foreach (ControlType controlType in controlTypes) { //create automation tests filter for the controlType FilterControlTypeTests controlTypeFilter = new FilterControlTypeTests(controlType); //create tree currentTestTypeRootNode for the control type TreeNode controlTypeNode = new TreeNode(controlTypeFilter.ControlTypeName); currentTestTypeRootNode.Nodes.Add(controlTypeNode); //create priority subtree for the controlType CreatePrioritySubtreesForTestType(controlTypeNode, new AndFilter(testFilter, controlTypeFilter), testType); //if the currentRootNode has no children nodes then remove it if (controlTypeNode.Nodes.Count == 0) controlTypeNode.Remove(); } } else { if (testType == TestTypes.PatternTest) { //if PatternTest test type is required then let's get all supported patterns //for the selected automation element. If we are showing all tests, not only for selected //elements then let's get all automation element Patterns. //for all grabbed Patterns let's create subtree with tests IEnumerable<AutomationPattern> supportedPatterns; if (this._scope == TestsScope.SelectedElementTests) { try { //get all supported patterns supportedPatterns = this._selectedElement.GetSupportedPatterns(); } catch (ElementNotAvailableException) { //is there is problem with the element then ignore his patterns supportedPatterns = new AutomationPattern[0]; } } else { //let's get all automation technology patterns supportedPatterns = AutomationHelper.GetAllAutomationPatterns(); } //for each pattern let's create subtree foreach (AutomationPattern pattern in supportedPatterns) { //create filter filtering automation tests testing this pattern FilterPatternTests patternFilter = new FilterPatternTests(pattern); //create tree currentRootNode for the pattern TreeNode patternNode = new TreeNode(patternFilter.PatternName); currentTestTypeRootNode.Nodes.Add(patternNode); //create priority subtree for the pattern CreatePrioritySubtreesForTestType(patternNode, new AndFilter(testFilter, patternFilter), testType); //if the currentRootNode has no children nodes then remove it if (patternNode.Nodes.Count == 0) patternNode.Remove(); } } else { //if other TestType than ControlTests or PatternTests is required then //create subtree for it CreatePrioritySubtreesForTestType(currentTestTypeRootNode, testFilter, testType); } } //if there are no children then remove the currentTestTypeRootNode if (currentTestTypeRootNode.Nodes.Count == 0) currentTestTypeRootNode.Remove(); }
/// <summary> /// create subtree for currentRootNode according to the testType and testFilter /// </summary> private void CreatePrioritySubtreesForTestType(TreeNode node, AutomationTestsFilter testFilter, TestTypes testType) { //go thru all test priorities and create subtree for each foreach (TestPriorities priority in Enum.GetValues(typeof(TestPriorities))) { if (priority != TestPriorities.None && (this._priorities & priority) == priority) CreateTestPrioritySubtree(priority, testType, node, testFilter); } }
/// <summary> /// create subtree for parentNode according to the testPriority, testType and testFilter /// </summary> private void CreateTestPrioritySubtree(TestPriorities testPriority, TestTypes testType, TreeNode parentNode, AutomationTestsFilter testFilter) { //create node for the priority TreeNode priorityNode = new TreeNode(GetPriorityName(testPriority)); parentNode.Nodes.Add(priorityNode); TreeNode currentRootNode = priorityNode; //create filter for the priority AndFilter priorityFilter = new AndFilter(new TestFilterPriority(testPriority), testFilter); //for all filtered available automation tests lets create tree node foreach (AutomationTest test in AutomationTestCollection.Filter(priorityFilter)) { //lets make copy ot the test with only TestType and TestPriority belonging to this //branch AutomationTest testClone = new AutomationTest(test, testPriority, testType); TreeNode testNode = new TreeNode(testClone.Name); testNode.Tag = testClone; currentRootNode.Nodes.Add(testNode); } //if no child currentTestTypeRootNode was added then remove priority currentTestTypeRootNode if (currentRootNode.Nodes.Count == 0) currentRootNode.Remove(); }
/// <summary>Initializes a new instance of the <see cref="MakeTestsAttribute"></see> class.</summary> public MakeTestsAttribute(Type typeUnderTest, TestTypes testTypes) { TypeUnderTest = typeUnderTest; TestTypes = testTypes; }
public void StorageScuMoveOriginatorTest() { int port = 2112; _serverHandlerList.Clear(); /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); string moveOriginatorAe = "ORIGINATOR"; ushort moveOriginatorId = 999; StorageScu scu = SetupScu(moveOriginatorAe, moveOriginatorId); IList<DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; scu.AddStorageInstance(new StorageInstance(file)); } scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning); var handler = CollectionUtils.FirstElement(_serverHandlerList); var serverHandler = handler as ServerHandler; Assert.NotNull(serverHandler); foreach (var message in serverHandler.MessagesReceived) { Assert.AreEqual(message.MoveOriginatorApplicationEntityTitle, moveOriginatorAe); Assert.AreEqual(message.MoveOriginatorMessageId, moveOriginatorId); } // StopListening DicomServer.StopListening(serverParameters); }
static void PrintTestList (TestTypes setType, bool printDescriptions) { // check for required option if (!GetOption ("testcaselib").Set) { ErrorWriteLine ("You must specify a test case library to list available tests."); ErrorWriteLine (); return; } if (GetOption ("set").Set) Console.WriteLine ("Available tests in {0}:", setType); else Console.WriteLine ("Available tests:"); if (!printDescriptions) Console.WriteLine (" (Use -listdesc to get a full description for each test.)"); Console.WriteLine (); foreach (Assembly asm in LoadTestAssemblies ()) { bool foundAtLeastOne = false; foreach (Type type in asm.GetTypes ()) if (type.IsSubclassOf (typeof (CodeDomTest))) { // instantiate the test to get the name, description // and type CodeDomTest test = null; try { ConstructorInfo cons = type.GetConstructor (new Type[0]); test = (CodeDomTest) cons.Invoke (new Object[0]); } catch (Exception e) { ErrorWriteLine ("Couldn't create instance of '{0}'.", type); ErrorWriteLine ("Exception stack: {0}", e.ToString ()); return; } foundAtLeastOne = true; if (test != null && (GetOption ("set").Set ? (test.TestType & setType) > 0 : true)) if (printDescriptions) Console.WriteLine (" {0}{1} * Set: {3}{1} {2}{1}", test.Name, Environment.NewLine, test.Description, Enum.Format (typeof (TestTypes), test.TestType, "F")); else Console.WriteLine (" - {0}", test.Name); } if (!foundAtLeastOne) { ErrorWriteLine ("Couldn't find at least one type that inherits from CodeDomTest in"); ErrorWriteLine (asm.CodeBase); ErrorWriteLine ("Make sure your test case assembly references the same CodeDomTest.dll"); ErrorWriteLine ("that the current program ({0}) does.", (Environment.GetCommandLineArgs ())[0]); } } }
public TestCondition(TestTypes test) { TestType = test; }
// Load tests from the test case assemblies static ArrayList LoadTests (ArrayList testAssemblies, TestTypes setType) { // determine specific tests to run from the commandline // if none are given, list.Count=0 signals to run them all ArrayList runTests = new ArrayList (); StringCollection specTests = GetOption ("runtestcase").Values; StringCollection dontRun = GetOption ("dontruntestcase").Values; StringCollection duplicateCheck = new StringCollection (); // while looping through the assemblies, this will reflect // whether or not a certain test was found BitArray specTestFound = new BitArray (specTests.Count); // check to see if there are any tests that were both // specified to run and specified NOT to run foreach (string specTest in specTests) { if (StringCollectionContainsIgnoreCase (dontRun, specTest)) { throw new InvalidOperationException (String.Format (CultureInfo.CurrentCulture, "Test '{0}' was both specified to run and *not* to run. " + "This is ambiguous. Giving up.", specTest)); } } foreach (Assembly asm in testAssemblies) { bool foundAtLeastOneTest = false; foreach (Type type in asm.GetTypes ()) { if (!type.Equals (typeof (CodeDomTest)) && !type.Equals (typeof (CodeDomTestTree)) && type.IsSubclassOf (typeof (CodeDomTest))) { CodeDomTest test = null; try { ConstructorInfo cons = type.GetConstructor (new Type[0]); test = (CodeDomTest) cons.Invoke (new Object[0]); } catch (Exception e) { throw new InvalidOperationException (String.Format (CultureInfo.CurrentCulture, "Couldn't create instance of '{0}': {1}", type, e.Message)); } // check for duplicate names if (test != null && StringCollectionContainsIgnoreCase (duplicateCheck, test.Name)) { throw new InvalidOperationException (String.Format (CultureInfo.CurrentCulture, " *** Found a duplicate test name '{0}' among test case assemblies. Check your test cases.", test.Name)); } else if (test != null) { duplicateCheck.Add (test.Name); } // if we got here, we found at least one type that inherits // from CodeDomTest and we were able to instantiate it if (test != null) foundAtLeastOneTest = true; // if certain tests were specified attempt to find them // NOTE: All test cases that match the given name will be // picked up for running. This includes test cases // that share the same name if (test != null && (GetOption ("set").Set ? (test.TestType & setType) > 0 : true) && !StringCollectionContainsIgnoreCase (dontRun, test.Name)) { if (specTests.Count > 0) { int index = -1; for (int i = 0; i < specTests.Count; i++) if (String.Compare ((string) specTests[i], test.Name, true, CultureInfo.InvariantCulture) == 0) { index = i; break; } if (index >= 0) { specTestFound[index] = true; runTests.Add (test); } } else { // run them all runTests.Add (test); } } } } if (!foundAtLeastOneTest) { ErrorWriteLine ("Couldn't find at least one type that inherits from CodeDomTest in"); ErrorWriteLine (asm.CodeBase); ErrorWriteLine ("Make sure your test case assembly references the same CodeDomTest.dll"); ErrorWriteLine ("that the current program ({0}) does.", (Environment.GetCommandLineArgs ())[0]); ErrorWriteLine ("Continuing..."); } } if (specTests.Count > 0) { // check if any specified tests weren't found for (int i = 0; i < specTestFound.Count; i++) { if (!specTestFound[i]) { PrintTestList (setType, false); if (GetOption ("set").Set) { throw new InvalidOperationException (String.Format (CultureInfo.CurrentCulture, "Can't find test '{0}' in the set '{1}'." + " Above is the list of available test cases.", specTests[i], GetOption ("set").GetSingleValue ())); } else { throw new InvalidOperationException (String.Format (CultureInfo.CurrentCulture, "Can't find test '{0}' in any test case assemblies. " + " Above is the list of available test cases.", specTests[i])); } } } } return runTests; }
public EngineSpeedTest(SymmetricEngines Engine, CipherModes Mode, int DataSize, int KeySize, int Rounds, bool Encryption, bool Parallel, TestTypes TestType = TestTypes.FileIO) { _cipherType = Mode; _dataSize = DataSize; _roundCount = Rounds; _engineType = Engine; _isEncryption = Encryption; _isParallel = Parallel; _keySize = KeySize; _keyParam = GetKeyParams(); _testType = TestType; if (IsStreamCipher()) { _streamCipher = GetStreamEngine(); _streamCipher.Initialize(_keyParam); if (_isParallel && _engineType == SymmetricEngines.Fusion || _engineType == SymmetricEngines.Salsa) { if (_dataSize > MB100) _blockSize = MB100; else if (DataSize > MB10) _blockSize = MB10; else if (DataSize > MB1) _blockSize = MB1; else _blockSize = 1024; } else { _blockSize = 64000; } } else { _cipherEngine = GetCipher(); _cipherEngine.Initialize(_isEncryption, _keyParam); // set parallel if (_cipherEngine.GetType().Equals(typeof(CTR))) ((CTR)_cipherEngine).IsParallel = _isParallel; else if (_cipherEngine.GetType().Equals(typeof(CBC))) ((CBC)_cipherEngine).IsParallel = _isParallel; else if (_cipherEngine.GetType().Equals(typeof(CFB))) ((CFB)_cipherEngine).IsParallel = _isParallel; // set block if (_isParallel && (_cipherType.Equals(CipherModes.CTR) || _cipherType.Equals(CipherModes.CBC) && !_isEncryption || _cipherType.Equals(CipherModes.CFB) && !_isEncryption)) { if (_dataSize > MB100) _blockSize = MB100; else if (DataSize > MB10) _blockSize = MB10; else if (DataSize > MB1) _blockSize = MB1; else _blockSize = 1024; if (_cipherEngine.GetType().Equals(typeof(CTR))) ((CTR)_cipherEngine).ParallelBlockSize = _blockSize; else if (_cipherEngine.GetType().Equals(typeof(CBC))) ((CBC)_cipherEngine).ParallelBlockSize = _blockSize; else if (_cipherEngine.GetType().Equals(typeof(CFB))) ((CFB)_cipherEngine).ParallelBlockSize = _blockSize; } else { _blockSize = _cipherEngine.BlockSize; } } _inputBuffer = new byte[_blockSize]; _outputBuffer = new byte[_blockSize]; }
/// <summary> /// This method extracts test type of the test. /// </summary> private void ExtractTestType() { //we have to use hard-coded names because there is no other way how to get the type TestTypes testType = TestTypes.None; if (this.Method.ReflectedType.FullName.EndsWith(".AutomationElementTests")) testType |= TestTypes.AutomationElementTest; if (this.Method.ReflectedType.FullName.Contains(".Tests.Patterns.")) testType |= TestTypes.PatternTest; else if (this.Method.ReflectedType.FullName.Contains(".Tests.Controls.")) testType |= TestTypes.ControlTest; //else if (this.Method.ReflectedType.FullName.Contains(".Tests.Scenarios.")) // testType |= TestTypes.ScenarioTest; else if (this.Method.ReflectedType.FullName.EndsWith(".Tests.ControlObject")) testType |= TestTypes.ControlTest; //else // //in debug mode we will notidy user about notsupported test // //in release mode we will ignore this test // Debug.Fail("not supported TestType: " + this.Method.ReflectedType.FullName); this._testType = testType; }