Пример #1
0
        private bool InitializeForTest(ITestElement testElement, IRunContext runContext)
        {
            var runId = runContext.RunConfig.TestRun.Id;
            TestResultMessage failure = null;

            try {
                var vars = new TestProperties(testElement, runContext.RunConfig.TestRun.RunConfiguration);
                InitializeWorker(vars, runContext, testElement).GetAwaiter().GetResult();
                _remote.Initialize(_runContext);

                AttachDebuggerIfNeeded(runContext, _ide, vars);
            } catch (ArgumentException ex) {
                failure = GetFailure(ex, runId, testElement);
            } catch (TimeoutException ex) {
                failure = GetFailure(ex, runId, testElement);
            } catch (InvalidOperationException ex) {
                failure = GetFailure(ex, runId, testElement);
            } catch (Exception ex) {
                failure = GetFailure(ex, runId, testElement);
                failure.SystemException = ex;
            }

            if (failure != null)
            {
                runContext.ResultSink.AddResult(failure);
                runContext.StopTestRun();
                return(false);
            }
            return(true);
        }
Пример #2
0
        public void UpdateToolTip()
        {
            if (IsTestStep())
            {
                var testStep = TestScriptObject as TestStep;

                ToolTipText =
                    string.Format("Title:  {0}\r\nTest type:  {1}\r\nStatus:  {2}\r\nDescription:  {3}\r\nExpected:  {4}{5}",
                                  testStep.Title,
                                  testStep.TestType.ToString(),
                                  testStep.Status,
                                  testStep.Description != null ? testStep.Description : "None",
                                  testStep.ExpectedBehavior != null ? testStep.ExpectedBehavior : "None",
                                  testStep.TestType == TestType.Automated ? "\r\n\r\n" + testStep.TestAutomationDefinition.ToString() : null);
            }
            else
            {
                // Provide file path if test suite.
                var fileText = TestScriptObject is TestSuite ? $"File:  {TestProperties.ExpandString(((TestSuite)TestScriptObject).FilePath)}" : string.Empty;

                ToolTipText = string.Format("Title:  {0}\r\nStatus:  {1}\r\n{2}\r\nDescription:  {3}",
                                            TestScriptObject.Title,
                                            TestScriptObject.Status,
                                            fileText,
                                            TestScriptObject.Description != null ? TestScriptObject.Description : "None");
            }
        }
Пример #3
0
 private TestMethod(string path, string name, int line, TestProperties testProperties)
 {
     Path           = path;
     Name           = name;
     Line           = line;
     TestProperties = testProperties;
 }
Пример #4
0
 public void TestIndexers()
 {
     using (var indexedProperties = new TestIndexedProperties())
     {
         Assert.AreEqual(1, indexedProperties[0]);
         Assert.AreEqual(1, indexedProperties["foo"]);
         indexedProperties[0] = 2;
         Assert.AreEqual(2, indexedProperties[0]);
         indexedProperties[0f] = 3;
         Assert.AreEqual(3, indexedProperties[0f]);
         var properties = indexedProperties[(byte)0];
         Assert.AreEqual(0, properties.Field);
         var newProperties = new TestProperties();
         newProperties.Field        = 4;
         indexedProperties[(byte)0] = newProperties;
         Assert.AreEqual(4, indexedProperties[(byte)0].Field);
         newProperties = indexedProperties[(short)0];
         Assert.AreEqual(4, newProperties.Field);
         newProperties.Field = 5;
         Assert.AreEqual(5, indexedProperties[(byte)0].Field);
         var bar = new Bar {
             A = 5
         };
         indexedProperties[0u] = bar;
         Assert.That(bar.A, Is.EqualTo(indexedProperties[0u].A));
         indexedProperties[(ushort)0] = bar;
         Assert.That(bar.A, Is.EqualTo(indexedProperties[(ushort)0].A));
     }
 }
Пример #5
0
    public void TestProperties()
    {
        // Test field property
        using (var prop = new TestProperties())
        {
            Assert.That(prop.Field, Is.EqualTo(0));
            prop.Field = 10;
            Assert.That(prop.Field, Is.EqualTo(10));

            // Test getter/setter property
            prop.Field = 20;
            Assert.That(prop.FieldValue, Is.EqualTo(20));
            prop.FieldValue = 10;
            Assert.That(prop.FieldValue, Is.EqualTo(10));

            prop.GetterAndSetterWithTheSameName = 25;
            Assert.That(prop.GetterAndSetterWithTheSameName, Is.EqualTo(25));

            prop.SetterReturnsBoolean = 35;
            Assert.That(prop.SetterReturnsBoolean, Is.EqualTo(35));

            prop.VirtualSetterReturnsBoolean = 45;
            Assert.That(prop.VirtualSetterReturnsBoolean, Is.EqualTo(45));

            Assert.That(prop.nestedEnum(), Is.EqualTo(5));
            Assert.That(prop.nestedEnum(55), Is.EqualTo(55));

            Assert.That(prop.Get32Bit, Is.EqualTo(10));
        }
    }
    public static void NegotiateStream_Http_AmbientCredentialsForNet50()
    {
        string testString = "Hello";
        ChannelFactory <IWcfService> factory = null;
        IWcfService serviceProxy             = null;

        try
        {
            // *** SETUP *** \\
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            string host = TestProperties.GetProperty(TestProperties.ServiceUri_PropertyName);

            factory = new ChannelFactory <IWcfService>(
                binding,
                new EndpointAddress(new Uri(Endpoints.Https_WindowsAuth_Address), new SpnEndpointIdentity($"HTTP/{host}")));
            serviceProxy = factory.CreateChannel();

            // *** EXECUTE *** \\
            string result = serviceProxy.Echo(testString);

            // *** VALIDATE *** \\
            Assert.Equal(testString, result);

            // *** CLEANUP *** \\
            ((ICommunicationObject)serviceProxy).Close();
            factory.Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
        }
    }
Пример #7
0
        public void GetHost()
        {
            TestTackerHandler handler    = new TestTackerHandler();
            TestProperties    properties = new TestProperties();

            properties.Group = "TEST";
            properties.Node  = "T1";
            properties.Host  = "192.168.0.121";
            properties.Port  = "8088";
            handler.Register(properties);
            properties       = new TestProperties();
            properties.Group = "TEST";
            properties.Node  = "T2";
            properties.Host  = "192.168.0.122";
            properties.Port  = "8088";
            handler.Register(properties);
            AppHost host = handler.GetHost(new TestProperties {
                Group = "TEST"
            });

            Assert.AreEqual("192.168.0.121", host.Host);
            Assert.AreEqual(8088, host.Port);
            host = handler.GetHost(new TestProperties {
                Group = "TEST"
            });
            Assert.AreEqual("192.168.0.122", host.Host);
            Assert.AreEqual(8088, host.Port);
        }
        private void openTestProperitesFile()
        {
            var openFileDialog = new OpenFileDialog();

            try
            {
                openFileDialog.Title            = "Quintity TestFramework - Load Test Properties";
                openFileDialog.InitialDirectory = TestProperties.ExpandString("[TestHome]\\TestProperties");
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Filter           = "Test properties (*.props)|*.props|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.FileName         = null;

                if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    newTestProperties(openFileDialog.FileName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, $"An error has occurred loading file \"{openFileDialog.FileName}\":" +
                                $"{Environment.NewLine}{Environment.NewLine}{e.Message}{Environment.NewLine}{Environment.NewLine}" +
                                "Please select another file.", "Quintity TestFramework",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #9
0
        /// <summary>
        /// Executes the test script object
        /// </summary>
        /// <param name="testScriptObject"></param>
        /// <param name="testCases"></param>
        private void executeTestScriptObject(ExecutionParameters executionParameters)
        {
            // Structuring this way as eventually the id or build might be a commmand line item for CI/CD
            if (TestProperties.GetProperty("TestRunId") == null)
            {
                // Not previously set, so create test run id and push to test properties.
                TestProperties.SetPropertyValue("TestRunId", DateTime.Now.Ticks.ToString());
            }

            SuppressExecution = executionParameters._suppressExecution;

            _initialTestScriptObject = executionParameters._testScriptObject;

            // Must be a case or step...
            if (executionParameters._testProfile == null)
            {
                executionParameters._testProfile = new TestProfile(1, new TimeSpan(0, 0, 0), "VirtualUser");
            }

            _mainExecutionThread      = new Thread(new ParameterizedThreadStart(executeOnMainThread));
            _mainExecutionThread.Name = "MainExecutionThread";
            _mainExecutionThread.SetApartmentState(ApartmentState.STA);
            _mainExecutionThread.IsBackground = true;
            _mainExecutionThread.Start(executionParameters);
        }
 private void initializeTestProfile()
 {
     try
     {
         if (!string.IsNullOrEmpty(Program.TestPerformanceFile))
         {
             m_testProfileUri           = new Uri(TestProperties.ExpandString(Program.TestPerformanceFile));
             m_testTreeView.TestProfile = TestProfile.ReadFromFile(m_testProfileUri.LocalPath);
         }
     }
     catch (FileNotFoundException)
     {
         MessageBox.Show(
             string.Format("Unable to locate test performance file \"{0}\".\r\n\r\nPlease verify the file path.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (SerializationException)
     {
         MessageBox.Show(
             string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (UriFormatException)
     {
         MessageBox.Show(
             string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private static void initializeTestProperties(string testPropertiesFile)
        {
            if (!string.IsNullOrEmpty(testPropertiesFile))
            {
                Uri testPropertiesUri = loadTestProperties(testPropertiesFile);

                if (testPropertiesUri == null)
                {
                    TestProperties.Initialize();
                }
            }
            else
            {
                TestProperties.Initialize();
            }

            if (!string.IsNullOrEmpty(testEnvironments))
            {
                var testPropertyOverrides = TestProperties.GetTestProperityOverrides(testEnvironments);

                if (testPropertyOverrides != null)
                {
                    TestProperties.ApplyTestPropertyOverrides(testPropertyOverrides);
                }
                else
                {
                    LogEvent.Info($"The test environment \"{testEnvironments }\" has been specified, " +
                                  "however it was not located in the application configuration file.");

                    exitCode = ExitCode.TestPropertiesError;
                }
            }
        }
        public override void OnTestExecutionBegin(TestExecutor testExecutor, TestExecutionBeginArgs args)
        {
            _totalPassed   = 0;
            _totalFailed   = 0;
            _totalErrored  = 0;
            _totalInactive = 0;

            string delimitedRecipients;

            _build        = Convert.ToString(TestProperties.GetPropertyValue("Build"));
            _buildTrigger = Convert.ToString(TestProperties.GetPropertyValue("BuildTrigger"));
            _mailHost     = Convert.ToString(TestProperties.GetPropertyValue("MailHost"));
            _port         = Convert.ToInt32(TestProperties.GetPropertyValue("Port"));
            _sender       = Convert.ToString(TestProperties.GetPropertyValue("Sender"));

            delimitedRecipients = Convert.ToString(TestProperties.GetPropertyValue("Recipients"));

            _recipients = delimitedRecipients.Split(new char[] { ';' });

            for (int i = 0; i < _recipients.Length; i++)
            {
                _recipients[i] = _recipients[i].Trim();
            }

            // Add computer information.
            appendToBody(string.Format("\r\nTester:  {0}\r\nHost machine:  {1}\r\nRun time:  {2}",
                                       Environment.UserName, Environment.MachineName, DateTime.Now.ToString("F")));
        }
Пример #13
0
        private void saveToFile()
        {
            try
            {
                // Collect new properties and assign properties
                TestProperties.SetTestPropertyCollection(collectTestProperties());

                // Save properties to fie.
                TestProperties.Save();
            }
            catch (TestPropertyEditorException e)
            {
                m_testPropertiesDataGridView.CurrentCell = m_testPropertiesDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                MessageBox.Show(this, e.Message,
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                m_testPropertiesDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
                m_testPropertiesDataGridView.BeginEdit(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Close();
            }
        }
        public void saveAsTestSuite()
        {
            try
            {
                m_saveFileDialog.Title            = "Save Test Suite As";
                m_saveFileDialog.InitialDirectory = TestProperties.TestSuites;
                m_saveFileDialog.RestoreDirectory = true;
                m_saveFileDialog.Filter           = "Test suites (*.ste)|*.ste";
                m_saveFileDialog.FilterIndex      = 1;

                DialogResult result = m_saveFileDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    TestSuite testSuite = new TestSuite(m_testTreeView.GetTestSuite(), m_saveFileDialog.FileName, null);

                    saveTestSuite(testSuite);
                    m_testTreeView.RootNode.TestScriptObject = testSuite;
                    m_testTreeView.RootNode.TestScriptResult = null;

                    // Clean up UI
                    m_testSuiteUri = new Uri(TestProperties.ExpandString(testSuite.FilePath));
                    setCaption();
                    m_fileSaveAsMenuItem.Enabled  = false;
                    m_saveToolStripButton.Enabled = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #15
0
 public static void OSID_Was_Detected()
 {
     Assert.True(OSHelper.Current != OSID.None,
                 String.Format("OSID was not properly detected from:{0}  TestProperties[TestNugetRuntimeId] = \"{1}\"{0}  RuntimeInformation.OSDescription = \'{2}\"",
                               Environment.NewLine,
                               TestProperties.GetProperty(TestProperties.TestNugetRuntimeId_PropertyName),
                               RuntimeInformation.OSDescription));
 }
 private NegotiateStreamTestConfiguration()
 {
     NegotiateTestRealm    = TestProperties.GetProperty(NegotiateTestRealm_PropertyName);
     NegotiateTestDomain   = TestProperties.GetProperty(NegotiateTestDomain_PropertyName);
     NegotiateTestUserName = TestProperties.GetProperty(NegotiateTestUserName_PropertyName);
     NegotiateTestPassword = TestProperties.GetProperty(NegotiateTestPassword_PropertyName);
     NegotiateTestSpn      = TestProperties.GetProperty(NegotiateTestSpn_PropertyName);
     NegotiateTestUpn      = TestProperties.GetProperty(NegotiateTestUpn_PropertyName);
 }
Пример #17
0
 public void TestRefToPrimitiveInSetter()
 {
     using (var testProperties = new TestProperties())
     {
         const double value = 5.5;
         testProperties.RefToPrimitiveInSetter = value;
         Assert.That(testProperties.RefToPrimitiveInSetter, Is.EqualTo(value));
     }
 }
Пример #18
0
    public void TestProperties()
    {
        // Test field property
        using (var prop = new TestProperties())
        {
            Assert.That(prop.Field, Is.EqualTo(0));
            prop.Field = 10;
            Assert.That(prop.Field, Is.EqualTo(10));

            // Test getter/setter property
            prop.Field = 20;
            Assert.That(prop.FieldValue, Is.EqualTo(20));
            prop.FieldValue = 10;
            Assert.That(prop.FieldValue, Is.EqualTo(10));

            prop.GetterAndSetterWithTheSameName = 25;
            Assert.That(prop.GetterAndSetterWithTheSameName, Is.EqualTo(25));

            prop.SetterReturnsBoolean = 35;
            Assert.That(prop.SetterReturnsBoolean, Is.EqualTo(35));
            Assert.That(prop.SetSetterReturnsBoolean(35), Is.False);
            Assert.That(prop.SetSetterReturnsBoolean(40), Is.True);

            prop.VirtualSetterReturnsBoolean = 45;
            Assert.That(prop.VirtualSetterReturnsBoolean, Is.EqualTo(45));
            Assert.That(prop.SetVirtualSetterReturnsBoolean(45), Is.False);
            Assert.That(prop.SetVirtualSetterReturnsBoolean(50), Is.True);

            Assert.That(prop.nestedEnum(), Is.EqualTo(5));
            Assert.That(prop.nestedEnum(55), Is.EqualTo(55));

            Assert.That(prop.Get32Bit, Is.EqualTo(10));
            Assert.That(prop.ConstRefField, Is.EqualTo(prop.Field));
            Assert.That(prop.IsEmpty, Is.EqualTo(prop.Empty));

            Assert.That(prop.VirtualGetter, Is.EqualTo(15));

            Assert.That(prop.StartWithVerb, Is.EqualTo(25));
            prop.StartWithVerb = 5;

            Assert.That(prop.Contains('a'), Is.EqualTo(prop.Contains("a")));

            Assert.That(prop.conflict, Is.EqualTo(CommonTest.TestProperties.Conflict.Value1));
            prop.conflict = CommonTest.TestProperties.Conflict.Value2;
            Assert.That(prop.conflict, Is.EqualTo(CommonTest.TestProperties.Conflict.Value2));

            prop.Callback = x => 4 * x;
            Assert.That(prop.Callback(5), Is.EqualTo(20));

            Assert.That(prop.ArchiveName, Is.EqualTo(20));
        }
        using (var prop = new HasOverridenSetter())
        {
            Assert.That(prop.VirtualGetter, Is.EqualTo(20));
            prop.SetVirtualGetter(5);
        }
    }
Пример #19
0
    public static bool GetCertificate(out byte[] certificateBytes)
    {
        string endpoint   = Endpoints.Https_DefaultBinding_Address;
        string bridgePort = TestProperties.GetProperty(TestProperties.BridgePort_PropertyName);

        certificateBytes = default(byte[]);

        Uri uri;

        try
        {
            if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out uri))
            {
                string certAsPemUri = string.Format(
                    "http://{0}:{1}/resource/WcfService.CertificateResources.CertificateAuthorityResource?exportAsPem=true", uri.Host, bridgePort);

                Console.WriteLine("  Bridge hostname is: '{0}'", uri.Host);
                Console.WriteLine("  Retrieving certificate from:");

                Console.WriteLine(certAsPemUri);
                Console.WriteLine();

                HttpClient client   = new HttpClient();
                var        response = client.GetAsync(certAsPemUri).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    certificateBytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
                    Console.WriteLine("    ... read {0} bytes from Bridge", certificateBytes.Length);
                    return(true);
                }
                else
                {
                    Console.WriteLine("  Received an unexpected response from Bridge:{0}  HTTP Status code {1}: '{2}'",
                                      Environment.NewLine,
                                      response.StatusCode,
                                      response.ReasonPhrase);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("  The Bridge uri specified: '{0}' is an invalid uri", endpoint);
                certificateBytes = null;
                return(false);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("  There was an exception thrown while accessing the Bridge at '{0}'", endpoint);
            Console.WriteLine();
            Console.WriteLine(ex);
        }

        return(false);
    }
Пример #20
0
    public static void TestProperties_All_Properties_Have_Values()
    {
        IEnumerable <string> propertyNames = TestProperties.PropertyNames;

        foreach (var name in propertyNames)
        {
            string value = TestProperties.GetProperty(name);
            Assert.True(value != null, String.Format("Property '{0}' should not be null.", name));
        }
    }
Пример #21
0
        public static void Save(string testListenersFile)
        {
            // Expand each assembly path.
            foreach (TestListenerDescriptor listener in _testListenersCollection)
            {
                string testlisteners = TestProperties.TestConfigs;
                listener.Assembly = TestProperties.FixupString(listener.Assembly, "TestListeners");
            }

            TestListenerCollection.SerializeToFile(_testListenersCollection, testListenersFile);
        }
Пример #22
0
        public void Constructor_ClassWith4Properties_CorrectNumberOfPropertiesCreated()
        {
            // Setup
            var propertyObject = new TestProperties();

            // Call
            var dynamicPropertyBag = new DynamicPropertyBag(propertyObject);

            // Assert
            Assert.AreEqual(4, dynamicPropertyBag.Properties.Count(), "Expected property count wrong");
        }
Пример #23
0
        public void GetClassName_Always_ReturnDynamicPropertyBagClassName()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            string className = dynamicPropertyBag.GetClassName();

            // Assert
            Assert.AreEqual(dynamicPropertyBag.GetType().FullName, className);
        }
Пример #24
0
        public void ToString_ReturnToStringFromWrappedObject()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            string text = dynamicPropertyBag.ToString();

            // Assert
            Assert.AreEqual(target.ToString(), text);
        }
Пример #25
0
        public void GetPropertyOwner_Always_ReturnWrappedObject()
        {
            // Setup
            var propertyObject     = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(propertyObject);

            // Call
            object owner = dynamicPropertyBag.GetPropertyOwner(null);

            // Assert
            Assert.AreSame(propertyObject, owner);
        }
Пример #26
0
        public void GetEditor_Always_ReturnNull()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            object editor = dynamicPropertyBag.GetEditor(typeof(UITypeEditor));

            // Assert
            Assert.IsNull(editor);
        }
Пример #27
0
        public void GetEventsParametered_Always_ReturnEmpty()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            EventDescriptorCollection events = dynamicPropertyBag.GetEvents(new Attribute[0]);

            // Assert
            CollectionAssert.IsEmpty(events);
        }
Пример #28
0
        public void GetConverter_Always_ReturnDefaultTypeConverter()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            TypeConverter typeConverter = dynamicPropertyBag.GetConverter();

            // Assert
            Assert.AreEqual(TypeDescriptor.GetConverter(dynamicPropertyBag, true), typeConverter);
        }
Пример #29
0
        public void GetComponentName_Always_ReturnNull()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            string componentName = dynamicPropertyBag.GetComponentName();

            // Assert
            Assert.IsNull(componentName);
        }
Пример #30
0
        public void GetDefaultEvent_Always_ReturnNull()
        {
            // Setup
            var target             = new TestProperties();
            var dynamicPropertyBag = new DynamicPropertyBag(target);

            // Call
            EventDescriptor eventDescriptor = dynamicPropertyBag.GetDefaultEvent();

            // Assert
            Assert.IsNull(eventDescriptor);
        }
Пример #31
0
 public void Register()
 {
     TestTackerHandler handler = new TestTackerHandler();
     TestProperties properties = new TestProperties();
     properties.Group = "TEST";
     properties.Node = "T1";
     properties.Host = "192.168.0.121";
     properties.Port = "8088";
     handler.Register(properties);
     AppHost host = handler.GetHost(new TestProperties { Group = "TEST" });
     Assert.AreEqual(properties.Host,host.Host );
     Assert.AreEqual(properties.Port, host.Port.ToString());
 }
Пример #32
0
 public void GetInfo()
 {
     TestTackerHandler handler = new TestTackerHandler();
     TestProperties properties = new TestProperties();
     properties.Group = "TEST";
     properties.Node = "T1";
     properties.Host = "192.168.0.121";
     properties.Port = "8088";
     handler.Register(properties);
     properties = new TestProperties();
     properties.Group = "TEST";
     properties.Node = "T2";
     properties.Host = "192.168.0.122";
     properties.Port = "8088";
     handler.Register(properties);
     //Group group = (Group)handler.GetInfo(new TestProperties { Group = "TEST" });
     //Assert.AreEqual("T1", group.Nodes[0].Name);
     //Assert.AreEqual("T2", group.Nodes[1].Name);
 }
Пример #33
0
        public TestsFile ParseTestsFile(string testsFile)
        {
            TestsFile result = new TestsFile();
            using (var fs = File.OpenRead(testsFile))
            {
                using (var br = new BinaryReader(fs))
                {
                    TestsFileHeader header = new TestsFileHeader();
                    header.RecSizeLabel = ConvertToString(br.ReadBytes(8));
                    header.RecSize = br.ReadInt32();
                    header.Unknown = br.ReadInt32();
                    result.Header = header;

                    result.Tests = new List<TestProperties>();
                    while (fs.Length > fs.Position)
                    {
                        var test = new TestProperties();
                        using (var ms = new MemoryStream(br.ReadBytes(header.RecSize)))
                        {
                            using (var br1 = new BinaryReader(ms))
                            {
                                // 读取TestIdentity
                                var identity = new TestIdentity();
                                // identity.Name = ConvertToString(br1.ReadBytes(21));
                                identity.Name = ConvertToGBString(br1.ReadBytes(21));
                                identity.Instrument = ConvertToString(br1.ReadBytes(11));
                                identity.GelSize = br1.ReadInt16();
                                identity.StainType = br1.ReadInt16();
                                test.Identity = identity;

                                // 
                                test.bIFE = br1.ReadBoolean();
                                test.Units = ConvertToString(br1.ReadBytes(11));
                                test.TotalUnits = ConvertToString(br1.ReadBytes(11));
                                test.AutoEditOptions = br1.ReadByte();
                                test.Precision = br1.ReadInt16();
                                test.UnitsFullScale = br1.ReadInt16();
                                test.ImageContrast = br1.ReadInt16();

                                // 读取DemoIdentity
                                var demos = new List<DemoIdentity>();
                                for (int i = 0; i < 10; i++)
                                {
                                    DemoIdentity d = new DemoIdentity();
                                    d.Label = ConvertToString(br1.ReadBytes(21));
                                    d.Type = br1.ReadByte();
                                    d.ASTMField = br1.ReadByte();
                                    demos.Add(d);
                                }
                                test.Demo = demos;

                                // 读取RangeSet
                                var rs = new List<Range>();
                                for (int i = 0; i < 9; i++)
                                {
                                    Range r = new Range();
                                    r.Sex = ConvertToString(br1.ReadBytes(2));
                                    r.Type = br1.ReadByte();
                                    r.AgeLow = br1.ReadByte();
                                    r.AgeLowUnits = br1.ReadByte();
                                    r.AgeHigh = br1.ReadByte();
                                    r.AgeHighUnits = br1.ReadByte();
                                    rs.Add(r);
                                }
                                test.RangeSet = rs;

                                br1.ReadByte();

                                // 读取Ratio
                                var ratios = new List<Ratio>();
                                for (int i = 0; i < 2; i++)
                                {
                                    Ratio r = new Ratio();
                                    r.Label = Encoding.ASCII.GetString(br1.ReadBytes(12));
                                    r.dRange = new List<KeyValuePair<double, double>>();
                                    for (int j = 0; j < 9; j++)
                                    {
                                        KeyValuePair<double, double> t = new KeyValuePair<double, double>(br1.ReadDouble(), br1.ReadDouble());
                                        r.dRange.Add(t);
                                    }
                                    ratios.Add(r);
                                }
                                test.Ratio = ratios;

                                // 读取Fraction
                                var fractions = new List<Fraction>();
                                for (int i = 0; i < 10 + 1; i++)
                                {
                                    Fraction f = new Fraction();
                                    f.Label = ConvertToString(br1.ReadBytes(13));
                                    f.Ratio = new List<byte>();
                                    f.Ratio.Add(br1.ReadByte());
                                    f.Ratio.Add(br1.ReadByte());
                                    f.bIstd = br1.ReadBoolean();
                                    f.dPctRange = new List<KeyValuePair<double, double>>();
                                    for (int j = 0; j < 9; j++)
                                    {
                                        KeyValuePair<double, double> t = new KeyValuePair<double, double>(br1.ReadDouble(), br1.ReadDouble());
                                        f.dPctRange.Add(t);
                                    }
                                    f.dUnitsRange = new List<KeyValuePair<double, double>>();
                                    for (int j = 0; j < 9; j++)
                                    {
                                        KeyValuePair<double, double> t = new KeyValuePair<double, double>(br1.ReadDouble(), br1.ReadDouble());
                                        f.dUnitsRange.Add(t);
                                    }
                                    fractions.Add(f);
                                }
                                test.Fraction = fractions;

                                // 不读取了
                                //test.RstrctBandLabel = ConvertToString(br1.ReadBytes(18));
                                //test.Reserved = Encoding.ASCII.GetString(br1.ReadBytes(2));
                                //test.Options = br1.ReadByte();
                            }
                        }
                        result.Tests.Add(test);
                    }
                }
            }
            return result;
        }
Пример #34
0
    public void TestProperties()
    {
        // Test field property
        var prop = new TestProperties();
        Assert.That(prop.Field, Is.EqualTo(0));
        prop.Field = 10;
        Assert.That(prop.Field, Is.EqualTo(10));

        // Test getter/setter property
        prop.Field = 20;
        Assert.That(prop.FieldValue, Is.EqualTo(20));
        prop.FieldValue = 10;
        Assert.That(prop.FieldValue, Is.EqualTo(10));
    }
Пример #35
0
 public unsafe void TestIndexers()
 {
     var indexedProperties = new TestIndexedProperties();
     Assert.AreEqual(1, indexedProperties[0]);
     Assert.AreEqual(1, indexedProperties["foo"]);
     indexedProperties[0] = 2;
     Assert.AreEqual(2, indexedProperties[0]);
     indexedProperties[0f] = 3;
     Assert.AreEqual(3, indexedProperties[0f]);
     var properties = indexedProperties[(byte)0];
     Assert.AreEqual(0, properties.Field);
     var newProperties = new TestProperties();
     newProperties.Field = 4;
     indexedProperties[(byte)0] = newProperties;
     Assert.AreEqual(4, indexedProperties[(byte)0].Field);
     newProperties = indexedProperties[(short)0];
     Assert.AreEqual(4, newProperties.Field);
     newProperties.Field = 5;
     Assert.AreEqual(5, indexedProperties[(byte)0].Field);
 }
Пример #36
0
 public void TestIndexers()
 {
     using (var indexedProperties = new TestIndexedProperties())
     {
         Assert.AreEqual(1, indexedProperties[0]);
         Assert.AreEqual(1, indexedProperties["foo"]);
         indexedProperties[0] = 2;
         Assert.AreEqual(2, indexedProperties[0]);
         indexedProperties[0f] = 3;
         Assert.AreEqual(3, indexedProperties[0f]);
         var properties = indexedProperties[(byte) 0];
         Assert.AreEqual(0, properties.Field);
         var newProperties = new TestProperties();
         newProperties.Field = 4;
         indexedProperties[(byte) 0] = newProperties;
         Assert.AreEqual(4, indexedProperties[(byte) 0].Field);
         newProperties = indexedProperties[(short) 0];
         Assert.AreEqual(4, newProperties.Field);
         newProperties.Field = 5;
         Assert.AreEqual(5, indexedProperties[(byte) 0].Field);
         var bar = new Bar { A = 5 };
         indexedProperties[0u] = bar;
         Assert.That(bar.A, Is.EqualTo(indexedProperties[0u].A));
         indexedProperties[(ushort) 0] = bar;
         Assert.That(bar.A, Is.EqualTo(indexedProperties[(ushort) 0].A));
     }
 }
Пример #37
0
        /// <summary>
        /// Creates and shows an Item context menu at the mouse pointer
        /// </summary>
        public ContextMenuStrip ItemContextMenu()
        {
            var top = new ToolStripMenuItem("Move to &Top");
            top.Click += (o, args) =>
            {
                SetItem(SelectedScene.MoveItem(SelectedItem, obs_order_movement.OBS_ORDER_MOVE_TOP));
            };

            var up = new ToolStripMenuItem("Move &Up");
            up.Click += (o, args) =>
            {
                SetItem(SelectedScene.MoveItem(SelectedItem, obs_order_movement.OBS_ORDER_MOVE_UP));
            };

            var down = new ToolStripMenuItem("Move &Down");
            down.Click += (o, args) =>
            {
                SetItem(SelectedScene.MoveItem(SelectedItem, obs_order_movement.OBS_ORDER_MOVE_DOWN));
            };

            var bottom = new ToolStripMenuItem("Move to &Bottom");
            bottom.Click += (o, args) =>
            {
                SetItem(SelectedScene.MoveItem(SelectedItem, obs_order_movement.OBS_ORDER_MOVE_BOTTOM));
            };

            var transform = new ToolStripMenuItem("&Edit Transform Options...");
            transform.Click += (o, args) =>
            {
                var transformfrm = new TestTransform(SelectedItem);
                transformfrm.ShowDialog();
            };

            var prop = new ToolStripMenuItem("&Edit Source Properties...");
            prop.Click += (sender, args) =>
            {
                var propfrm = new TestProperties(SelectedItem.GetSource());
                propfrm.ShowDialog();
            };

            var visible = new ToolStripBindableMenuItem
                          {
                              Text = "&Visible",
                              CheckOnClick = true
                          };
            visible.DataBindings.Add(new Binding("Checked", SelectedItem, "Visible", false, DataSourceUpdateMode.OnPropertyChanged));

            var ordermenu = new ContextMenuStrip
                            {
                                Renderer = new AccessKeyMenuStripRenderer()
                            };

            ordermenu.Items.AddRange(new ToolStripItem[]
                                     {
                                         top,
                                         up,
                                         down,
                                         bottom,
                                         new ToolStripSeparator(),
                                         visible,
                                         new ToolStripSeparator(),
                                         transform,
                                         prop
                                     });

            int index = SelectedScene.Items.IndexOf(SelectedItem);
            top.Enabled = up.Enabled = index != 0;
            down.Enabled = bottom.Enabled = index != SelectedScene.Items.Count - 1;
            return ordermenu;
        }
Пример #38
0
        /// <summary>
        /// Creates and shows a Source context menu at the mouse pointer
        /// </summary>
        public ContextMenuStrip SourceContextMenu()
        {
            var filtermenu = new ContextMenuStrip { Renderer = new AccessKeyMenuStripRenderer() };

            var enabled = new ToolStripBindableMenuItem
            {
                Text = "&Enabled",
                CheckOnClick = true,
            };
            enabled.DataBindings.Add(new Binding("Checked", SelectedSource, "Enabled", false, DataSourceUpdateMode.OnPropertyChanged));

            var muted = new ToolStripBindableMenuItem
            {
                Text = "&Muted",
                CheckOnClick = true,
            };
            muted.DataBindings.Add(new Binding("Checked", SelectedSource, "Muted", false, DataSourceUpdateMode.OnPropertyChanged));

            var filters = new ToolStripMenuItem("Edit Source Filters...");
            filters.Click += (sender, args) =>
            {
                var filterprop = new TestFilter(SelectedSource);
                filterprop.ShowDialog();
            };

            var properties = new ToolStripMenuItem("Edit Source Properties...");
            properties.Click += (sender, args) =>
            {
                var sourceprop = new TestProperties(SelectedSource);
                sourceprop.ShowDialog();
            };

            filtermenu.Items.AddRange(new ToolStripItem[]
                                      {
                                          enabled,
                                          muted,
                                          new ToolStripSeparator(),
                                          filters,
                                          properties
                                      });

            return filtermenu;
        }