//   public Dictionary<string, List<string>> MatchedSurfaceIds;
     //   public Dictionary<string, List<string>> MatchedOpening;

        public void Clear()
        {
            testSummary = "";
            testReasoning = "";

            if (standResult != null)
                standResult.Clear();

            if (testResult != null)
                testResult.Clear();

            if (idList != null)
                idList.Clear();
            tolerance = DOEgbXMLBasics.Tolerances.ToleranceDefault;
            lengthtol = DOEgbXMLBasics.Tolerances.ToleranceDefault;
            vectorangletol = DOEgbXMLBasics.Tolerances.ToleranceDefault;
            coordtol = DOEgbXMLBasics.Tolerances.ToleranceDefault;
            testType = TestType.None;
            subTestIndex = -1;
            passOrFail = false;
            if (MessageList != null) { MessageList.Clear(); }
            if (TestPassedDict != null) { TestPassedDict.Clear(); }
            longMsg = "";

        }
예제 #2
0
파일: MainForm.cs 프로젝트: dearz/Practice
 public void ShowAbstractFactory()
 {
     TestType tt = new TestType();
     ISomething sm = SomethingFactory.CreateSomething();
     sm.InsertSomething(tt);
     sm.GetSomething("1234");
 }
예제 #3
0
 public void Update_Should_Update_A_TestType() 
 {
     _repository
          .Setup(it => it.Update(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<Boolean>(), It.IsAny<Int32>()))
          .Callback<String, String, Boolean, Int32>((name, testValidatorType, isActive, id) => 
     { 
          var tTestType = _repositoryList.Find(x => x.Id==id);
          tTestType.Name = name; 
          tTestType.TestValidatorType = testValidatorType; 
          tTestType.IsActive = isActive; 
     });
     var tempTestType = _repositoryList.Find(x => x.Id==id);
     var testTestType = new TestType {
          Id = tempTestType.Id, 
          Name = tempTestType.Name, 
          TestValidatorType = tempTestType.TestValidatorType, 
          IsActive = tempTestType.IsActive};
     
     //TODO change something on testTestType
     //testTestType.oldValue = newValue; 
     _target.Update(testTestType);
     //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue);
     //TODO fail until we update the test above
     Assert.Fail();
 }
		public void AddHandlerWorks() {
			bool invoked = false;
			var c = new TestType();
			Type.AddHandler(c, "Evt", (EventHandler)((s, e) => invoked = true));
			c.Raise();
			Assert.AreEqual(invoked, true);
		}
예제 #5
0
 public TestResults( int totalRes, int correctRes, DateTime timeOfPassage, TestType type)
 {
     TotalRes = totalRes;
     CorrectRes = correctRes;
     TimeOfPassage = timeOfPassage;
     Type = type;
 }
예제 #6
0
        public static void RunTest(TestType type, int ThreadCount, CallbackFunction callBack, ITest target)
        {
            for (int i = 0; i < ThreadCount; i++)
            {
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (object sender, DoWorkEventArgs e) =>
                {
                    bool result = target.Test();
                    e.Result = result;

                };

                worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
                    {
                        if (callBack != null)
                        {
                            if (e.Error != null)
                            {
                                callBack(type, (bool)e.Result);
                            }
                            else
                            {
                                callBack(type, false);
                            }
                        }
                    };
                worker.RunWorkerAsync();
            }
        }
예제 #7
0
        public static TestResult RunTest(TestType testType)
        {
            const int repeat = 5;

            var spaces = new[]
            {
                new Space(1000, 1000),
                new Space(1200, 1200),
                new Space(1400, 1400),
                new Space(1600, 1600),
                new Space(1800, 1800),
                new Space(2000, 2000)
            };

            var watch = new Stopwatch();
            var testResult = new TestResult();

            foreach (var space in spaces)
            {
                space.RandomGenerate();

                var key = $"{space.HeightCount}x{space.WidthCount}";

                for (var i = 0; i < repeat; i++)
                {
                    watch.Start();

                    switch (testType)
                    {
                        case TestType.SingleThread:
                            space.NewGeneration();
                            break;
                        case TestType.MultiThread:
                            space.NewGenerationMultiThread();
                            break;
                        default:
                            throw new ArgumentOutOfRangeException(nameof(testType), testType, null);
                    }

                    watch.Stop();

                    testResult[key] = watch.ElapsedMilliseconds;

                    watch.Reset();
                }

                var eventArg = new IntermediateResult
                {
                    TestType = testType,
                    Min = testResult[key, GettingType.Min],
                    Max = testResult[key, GettingType.Max],
                    Size = key
                };

                NewGenerationDone?.Invoke(null, eventArg);
            }

            return testResult;
        }
        public void Big_long_expressions_work(TestState testState, TestType testType, string expected)
        {

            var actual = _queryStringBuilder
                .QueryStringWith(testState == TestState.All ? "" : "state=" + testState.ToString().EnumNameToTransportCase())
                .AndWith(testType == TestType.All ? "" : "type=" + testType.ToString().EnumNameToTransportCase())
                .Build();
            actual.Should().Be(expected);
        }
예제 #9
0
파일: Program.cs 프로젝트: prasannavl/Liara
        public override async Task ProcessAsync(ILiaraContext context)
        {
            // Anything put into content will be serialized into the stream, using the Formatter, 
            // which is in-turn automatically selected using the FormatSelector.

            var t = new TestType {Message = "Hello!", RequestPath = context.Request.Info.Uri.ToString()};
            context.Response.Content = t;
            await base.ProcessAsync(context);
        }
예제 #10
0
 public RevitLookupTestFuncInfo(string label, string desc, System.Type classType, TestFunc func, TestType tType)
 {
     m_label = label;
     m_desc = desc;
     m_classType = classType;
     m_isCategoryBased = false;
     m_testFunc = func;
     m_testType = tType;
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="TestMethodWrapperContainer"/> class.
		/// </summary>
		/// <param name="testMethodsWrapper">The test methods wrapper.</param>
		/// <param name="groupingField">The grouping field.</param>
		internal TestMethodWrapperContainer(string caption, IEnumerable<TestMethodWrapper> testMethodsWrapper, TestMethodGroupingField groupingField, TestType testType)
		{
			_caption = caption;
			_groupingField = groupingField;

			TestType = testType;

			TestMethodsWrapper = testMethodsWrapper;
			LazyLoading = true;
		}
 public void with_a_non_typed_option_that_does_not_exist_should_not_set()
 {
     var referenceType = new TestType();
     var result = OptionApplicator.Get<TestType>(new OptionSource[]{
         new OptionSource("test", "NonExistent", false, "bar")
     });
     Assert.AreEqual(referenceType.Flag, result.Flag);
     Assert.AreEqual(referenceType.IpEndpoint, result.IpEndpoint);
     Assert.AreEqual(referenceType.Name, result.Name);
 }
예제 #13
0
 public RevitLookupTestFuncInfo(string label, string desc, string categoryStr, TestFunc func, TestType tType)
 {
     m_label = label;
     m_desc = desc;
     m_classType = null;
     m_isCategoryBased = true;
     m_categoryStr = categoryStr;
     m_testFunc = func;
     m_testType = tType;
 }
예제 #14
0
 public ActionResult Edit(int id, TestType testType)
 {
     try
     {
         _dbTestTypeRepository.Update(testType);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(testType);
     }
 }
예제 #15
0
 public ActionResult Create(TestType testType)
 {
     try
     {
         _dbTestTypeRepository.Insert(testType);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(testType);
     }
 }
		public void ItShouldReturnFalseIfInnerSpecificationReturnsTrue(IFixture fixture, [Frozen]ISpecification<TestType> inner, TestType item)
		{
			// Arrange
			A.CallTo(() => inner.IsSatisfiedBy(item)).Returns(true);

			var sut = fixture.Create<NotSpecification<TestType>>();

			// Act
			var result = sut.IsSatisfiedBy(item);

			// Assert
			result.Should().BeFalse();
		} 
예제 #17
0
                public void Then_the_return_value_is_from_the_cache_when_the_key_is_present()
                {
                    //arrange / act
                    var result1 = new TestType().MyMethod1();

                    //assert
                    Assert.That(result1 == 2);

                    //arrange / act
                    var result2 = new TestType().MyMethod2(3, "test string");

                    //assert
                    Assert.That(result2 == 2);
                }
예제 #18
0
                public void Then_the_cache_item_is_automatically_recalculated_according_to_the_strategy()
                {
                    //arrange / act
                    var instance = new TestType();
                    var result = instance.MyMethod3();

                    //assert
                    Assert.That(result == 1);

                    Thread.Sleep(TimeSpan.FromSeconds(5)); //wait for auto recalculation to be performed

                    //assert
                    Assert.That(TestType.Counter > 1); //the method has been invoked automatically behind the scenes a number of times by a worker thread
                }
예제 #19
0
                public void Then_the_result_is_recalculated_as_if_no_caching_was_in_place()
                {
                    //arrange / act
                    var instance = new TestType();
                    var result = instance.MyMethod4();

                    //assert
                    Assert.That(result == 1);

                    //arrange / act
                    instance.MyMethod4();

                    //assert
                    Assert.That(TestType.Counter2 == 3); //the counter has been manually incremented once for each of the direct invocations, with one automatic calculation ocurring in the meantime
                }
예제 #20
0
        public void SimpleObjectRoundTrip()
        {
            var serializer = new SSJsonSerializer();

            var testObj = new TestType() { Name = "Foo", SomeValue = "Bar" };

            var serialized = serializer.Serialize(testObj);

            var deserialized = serializer.Deserialize(serialized);

            Assert.That(deserialized, Is.TypeOf<TestType>());

            Assert.That(((TestType)deserialized).Name, Is.EqualTo(testObj.Name));
            Assert.That(((TestType)deserialized).SomeValue, Is.EqualTo(testObj.SomeValue));
        }
예제 #21
0
    //Update (postive or negative) and total test count at the beginning of test scenario
    private void UpdateCounts(TestType testType)
    {
        if (TestType.PositiveTest == testType)
        {
            posTestCount++;
            totalTestCount++;
            return;
        }

        if (TestType.NegativeTest == testType)
        {
            negTestCount++;
            totalTestCount++;
            return;
        }
    }
 public static TestRunner GetTestRunner(
     TestType type, 
     MethodInfo testMethod, 
     object typeInstance)
 {
     switch (type)
     {
         case TestType.Normal:
             return new NormalTestRunner(testMethod, typeInstance);
         case TestType.ShouldThrow:
             return new ShouldThrowTestRunner(testMethod, typeInstance);
         default:
             throw new NotSupportedException(
                 "Test type has no supported runner at this moment");
     }
 }
 public void SerializeTest()
 {
     object obj = new TestType()
     {
         Id = 1,
         Name = "Deneme 1",
         NullProperty = null,
         DateTimeProperty = new DateTime(2012, 7, 26, 13, 21, 36, 0),
         GuidProperty = new Guid("38fa9452-4491-4a96-a48b-be0854f10286")
     };
     //string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual = JsonNetSerializerHelper.Serialize(obj);
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual, JsonString);
     Debug.Write(actual);
 }
        public void DeserializeTest()
        {
            //DeserializeTestHelper<GenericParameterHelper>();
            //TestType expected = default(T); // TODO: Initialize to an appropriate value
            var expected = new TestType()
                               {
                                   Id = 1,
                                   Name = "Deneme 1",
                                   NullProperty = null,
                                   DateTimeProperty = new DateTime(2012, 7, 26, 13, 21, 36),
                                   GuidProperty = new Guid("38fa9452-4491-4a96-a48b-be0854f10286")
                               };
            var actual = JsonNetSerializerHelper.Deserialize<TestType>(JsonString);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual, expected);
        }
        public void Can_select_constant_add_expression()
        {
            var expected = new TestType()
            {
                IntColumn = 7,
                BoolColumn = true,
                StringColumn = "test"
            };

            EstablishContext(10, expected);

            var actual = ConnectionString.OpenDbConnection().Select<TestType>(q => q.IntColumn == 4 + 3);

            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Count);
            CollectionAssert.Contains(actual, expected);
        }
예제 #26
0
        public void SerialzeTest()
        {
            var ttl = new List<TestType>();

            var tt1 = new TestType();
            var tt2 = new TestType();
            var tt3 = new TestType();
            var tt4 = new TestType();

            ttl.Add(tt1);
            ttl.Add(tt2);
            ttl.Add(tt3);
            ttl.Add(tt4);

            var json = Json.Serialize(ttl);
            Console.WriteLine(json);
        }
예제 #27
0
        public TestResult CreateTestResult(TestType type, string fullName,
                                           ResultState state = ResultState.Success, 
                                           Func<IEnumerable<TestResult>> children = null, 
                                           string stackTrace = null, 
                                           string description = null,
                                           IList categories = null,
                                           string agentName = null)
        {
            description = description ?? RandomValuesGenerator.GetRandomValue<string>();
            agentName = agentName ?? RandomValuesGenerator.GetRandomValue<string>();
            var splitted = (fullName ?? string.Empty).Split(new[]{'.'}, StringSplitOptions.RemoveEmptyEntries);

            var childResults = children != null ? children() : new TestResult[0];
            var testResult = new TestResult(new TestInfoWrapper
                                                {
                                                    TestName = new TestName
                                                                   {
                                                                       FullName = fullName,
                                                                       Name = splitted.Length > 0 ? splitted[splitted.Length - 1] : string.Empty
                                                                   },
                                                    Categories = categories,
                                                    IsSuite = type != TestType.TestMethod,
                                                    TestCount = type == TestType.TestMethod ? 1 : RandomValuesGenerator.GetRandomValue<int>(),
                                                    TestType = type.ToString()
                                                })
                                 {
                                     AssertCount = 1,
                                     Time = RandomValuesGenerator.GetRandomValue<double>()
                                 };
            if (state != ResultState.Success)
                testResult.SetResult(state,
                                     description,
                                     stackTrace);
            else
                testResult.Success(description);

            testResult.SetAgentName(agentName);

            foreach (var childResult in childResults)
            {
                testResult.AddResult(childResult);
            }

            return testResult;
        }
 public void Update(string name, string testValidatorType, bool isActive, int id)
 {
     using (var client = new HttpClient(_messageHandler, false))
     {
         client.BaseAddress = new Uri(_baseAddress);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         var testType = new TestType
         {
             Name = name,
             TestValidatorType = testValidatorType,
             IsActive = isActive,
             Id = id
         };
         var response = client.PutAsync(UrlBase, testType, new JsonMediaTypeFormatter()).Result;
         response.EnsureSuccessStatusCode();
     }
 }
     //   public Dictionary<string, List<string>> MatchedSurfaceIds;
     //   public Dictionary<string, List<string>> MatchedOpening;

        public void Clear()
        {

            if (standResult != null)
                standResult.Clear();

            if (testResult != null)
                testResult.Clear();

            if (idList != null)
                idList.Clear();
            tolerance = DOEgbXMLBasics.Tolerances.ToleranceDefault;
            testType = TestType.None;
            subTestIndex = -1;
            passOrFail = false;
            if (MessageList != null) { MessageList.Clear(); }
            if (TestPassedDict != null) { TestPassedDict.Clear(); }
            longMsg = "";
        }
		public void ItShouldReturnTheCorrectValueForAllPossibleLHSAndRHSCombinations(bool lhsResult, bool rhsResult, bool expected)
		{
			// Arrange
			var item = new TestType();

			var lhs = A.Fake<ISpecification<TestType>>();
			A.CallTo(() => lhs.IsSatisfiedBy(item)).Returns(lhsResult);

			var rhs = A.Fake<ISpecification<TestType>>();
			A.CallTo(() => rhs.IsSatisfiedBy(item)).Returns(rhsResult);

			var sut = new AndSpecification<TestType>(lhs, rhs);

			// Act
			var result = sut.IsSatisfiedBy(item);

			// Assert
			result.Should().Be(expected);
		}
예제 #31
0
 public void ConvertSqlTestStringToTestType_Success()
 {
     Assert.Equal(TestType.SqlTest, TestType.From("@sqltest"));
 }
        private void CommutativeRemove(CRDT.Application.Commutative.Set.LWW_SetWithVCService <TestType> sourceReplica, TestType value, VectorClock vectorClock, List <CRDT.Application.Commutative.Set.LWW_SetWithVCService <TestType> > downstreamReplicas)
        {
            sourceReplica.LocalRemove(value, vectorClock);

            foreach (var downstreamReplica in downstreamReplicas)
            {
                downstreamReplica.DownstreamRemove(value, vectorClock);
            }
        }
        private void ConvergentRemove(CRDT.Application.Convergent.Set.LWW_SetWithVCService <TestType> sourceReplica, TestType value, VectorClock vectorClock, List <CRDT.Application.Convergent.Set.LWW_SetWithVCService <TestType> > downstreamReplicas)
        {
            sourceReplica.LocalRemove(value, vectorClock);

            var(adds, removes) = sourceReplica.State;

            foreach (var downstreamReplica in downstreamReplicas)
            {
                downstreamReplica.Merge(adds, removes);
            }
        }
예제 #34
0
 public void ConvertXmlFromEnum_Success(TestType.Enumeration value)
 {
     Assert.Equal(TestType.LoadTest, TestType.From(value));
 }
예제 #35
0
 public void ConvertIntegrationTestStringToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.IntegrationTest, TestType.ToEnum("@integrationtest"));
 }
예제 #36
0
 public void ConvertSqlTestStringToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.SqlTest, TestType.ToEnum("@sqltest"));
 }
예제 #37
0
 public void ConvertStringToEnum_Fails(string value)
 {
     Assert.Throws <QAToolKitCoreException>(() => TestType.ToEnum(value));
 }
예제 #38
0
        public void Lookup_Removed_ReturnsFalse(HashSet <LWW_SetWithVCElement <TestType> > existingAdds, HashSet <LWW_SetWithVCElement <TestType> > existingRemoves, TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            _repository.PersistAdds(existingAdds.ToImmutableHashSet());
            _repository.PersistRemoves(existingRemoves.ToImmutableHashSet());

            _lwwSetService.DownstreamAssign(value, new VectorClock(clock.Add(node, 0)));
            _lwwSetService.DownstreamRemove(value, new VectorClock(clock.Add(node, 1)));

            var lookup = _lwwSetService.Lookup(value);

            Assert.False(lookup);
        }
예제 #39
0
 private void AssertExistsInRepository(TestType value, VectorClock vectorClock)
 {
     Assert.Equal(1, _repository.GetElements().Count(e => Equals(e.Value, value) &&
                                                     e.VectorClock.Equals(vectorClock)));
 }
예제 #40
0
 #pragma warning disable 1998
 public async Task <ActionResult <OtherType> > Bar(TestType test, string foobar)
 {
     return(null);
 }
예제 #41
0
 public void ConverIntegrationTestFromEnum_Success(TestType.Enumeration value)
 {
     Assert.Equal(TestType.IntegrationTest, TestType.From(value));
 }
예제 #42
0
 public ArkadeTestMock(string name, TestType testType, string description = null) :
     this(new TestId(TestId.TestKind.Unidentified, 0), name, testType, description)
 {
 }
        public void ReadObjects(TestType testType)
        {
            int         count1       = 100;
            int         count2       = 10;
            List <long> memoryUsages = new List <long>();
            List <Func <IDbContextConnectionClass> > contexts = PerformanceTestsHelper.GetMemoryTestsCollectionContextCreators();

            foreach (Func <IDbContextConnectionClass> createContext in contexts)
            {
                long initialUsedMemory = 0;
                long usedMemory        = 0;

                initialUsedMemory = PerformanceTestsHelper.GetCurrentUsedMemory();

                using (IDisposable disposableContextInterface = (IDisposable)createContext()) {
                    IDbContextConnectionClass contextInterface = (IDbContextConnectionClass)disposableContextInterface;
                    DbContext context = (DbContext)contextInterface;
                    context.ResetDatabase();

                    for (int companyIndex = 0; companyIndex < count1; companyIndex++)
                    {
                        string companySuffix = companyIndex.ToString();

                        Company company = new Company();
                        company.CompanyName = companySuffix;
                        company.Description = "Description" + companySuffix;

                        for (int officeIndex = 0; officeIndex < count2; officeIndex++)
                        {
                            string officeSuffix = officeIndex.ToString();
                            Office office       = new Office();
                            office.Name        = officeSuffix;
                            office.Description = "Description" + companySuffix;

                            company.Offices.Add(office);
                        }

                        contextInterface.Company.Add(company);
                    }
                    context.SaveChanges();
                }

                using (IDisposable disposableContextInterface = (IDisposable)createContext()) {
                    IDbContextConnectionClass contextInterface = (IDbContextConnectionClass)disposableContextInterface;
                    DbContext context = (DbContext)contextInterface;

                    if (testType == TestType.WithOnePermission)
                    {
                        SecurityDbContext securityDbContext = context as SecurityDbContext;
                        if (securityDbContext != null)
                        {
                            PerformanceTestsHelper.AddOneCollectionPermission(securityDbContext, SecurityOperation.Read);
                        }
                    }

                    if (testType == TestType.WithMultiplePermissions)
                    {
                        SecurityDbContext securityDbContext = context as SecurityDbContext;
                        if (securityDbContext != null)
                        {
                            PerformanceTestsHelper.AddMultipleCollectionPermissions(securityDbContext, SecurityOperation.Read);
                        }
                    }

                    List <Company> objects = contextInterface.Company.Select(obj => obj).Include(obj => obj.Offices).ToList();
                    Assert.AreEqual(count1, objects.Count);

                    for (int companyIndex = 1; companyIndex < count1; companyIndex++)
                    {
                        Assert.AreEqual(count2, objects[companyIndex].Offices.Count);
                    }
                }

                long beforeCollect = GC.GetTotalMemory(true);
                usedMemory = PerformanceTestsHelper.GetCurrentUsedMemory();

                memoryUsages.Add(usedMemory - initialUsedMemory);
            }

            double securedContextBytesGrow = PerformanceTestsHelper.GetSecuredContextValue(memoryUsages);
            double nativeContextBytesGrow  = PerformanceTestsHelper.GetNativeContextValue(memoryUsages);

            Assert.IsTrue(false, "our: " + securedContextBytesGrow.ToString() + " bytes, native: " + nativeContextBytesGrow.ToString() + " bytes");
        }
예제 #44
0
 public void ConvertLoadTestStringToTestType_Success()
 {
     Assert.Equal(TestType.LoadTest, TestType.From("@loadtest"));
 }
예제 #45
0
 public void ConvertIntegrationTestStringToTestType_Success()
 {
     Assert.Equal(TestType.IntegrationTest, TestType.From("@integrationtest"));
 }
예제 #46
0
 public void ConvertFromString_Fails(string value)
 {
     Assert.Throws <QAToolKitCoreException>(() => TestType.From(value));
 }
예제 #47
0
 public void ConvertSecurityTestStringToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.SecurityTest, TestType.ToEnum("@securitytest"));
 }
예제 #48
0
        public void Add_WithExistingValues_AddsElementToTheRepository(HashSet <LWW_SetWithVCElement <TestType> > adds, TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            _repository.PersistAdds(adds.ToImmutableHashSet());

            _lwwSetService.DownstreamAssign(value, new VectorClock(clock.Add(node, 0)));

            var repositoryValues = _repository.GetAdds();

            Assert.Contains(value, repositoryValues.Select(v => v.Value));
        }
예제 #49
0
 public void ConvertLoadTestStringToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.LoadTest, TestType.ToEnum("@loadtest"));
 }
예제 #50
0
 public void ConvertLoadTestObjectToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.LoadTest, TestType.ToEnum(TestType.LoadTest));
 }
예제 #51
0
 public void ConvertIntegrationTestObjectToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.IntegrationTest, TestType.ToEnum(TestType.IntegrationTest));
 }
예제 #52
0
        /// <summary>
        /// Gets or creates test element.
        /// </summary>
        /// <param name="executionId"></param>
        /// <param name="parentExecutionId"></param>
        /// <param name="testType"></param>
        /// <param name="parentTestElement"></param>
        /// <param name="rockSteadyTestCase"></param>
        /// <returns>Trx test element</returns>
        private ITestElement GetOrCreateTestElement(Guid executionId, Guid parentExecutionId, TestType testType, ITestElement parentTestElement, ObjectModel.TestResult rockSteadyTestResult)
        {
            ITestElement testElement = parentTestElement;

            // For scenarios like data driven tests, test element is same as parent test element.
            if (parentTestElement != null && !parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType))
            {
                return(testElement);
            }

            TestCase testCase = rockSteadyTestResult.TestCase;
            Guid     testId   = this.converter.GetTestId(testCase);

            // Scenario for inner test case when parent test element is not present.
            var testName = testCase.DisplayName;
            var adapter  = testCase.ExecutorUri.ToString();

            if (adapter.Contains(TrxLoggerConstants.MstestAdapterString) &&
                parentTestElement == null &&
                !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName))
            {
                // Note: For old mstest adapters hierarchical support was not present. Thus inner result of data driven was identified using test result display name.
                // Non null test result display name means its a inner result of data driven/ordered test.
                // Changing GUID to keep supporting old mstest adapters.
                testId   = Guid.NewGuid();
                testName = rockSteadyTestResult.DisplayName;
            }

            // Get test element
            testElement = GetTestElement(testId);

            // Create test element
            if (testElement == null)
            {
                testElement = this.converter.ToTestElement(testId, executionId, parentExecutionId, testName, testType, testCase);
                testElements.TryAdd(testId, testElement);
            }

            return(testElement);
        }
예제 #53
0
 public void ConvertSecurityTestObjectToEnum_Success()
 {
     Assert.Equal(TestType.Enumeration.SecurityTest, TestType.ToEnum(TestType.SecurityTest));
 }
예제 #54
0
 public void ConvertSecurityTestFromString_Success(string value)
 {
     Assert.Equal(TestType.SecurityTest, TestType.From(value));
 }
예제 #55
0
 public void ConvertLoadTestFromString_Success(string value)
 {
     Assert.Equal(TestType.LoadTest, TestType.From(value));
 }
예제 #56
0
 public void ConverIntegrationTestFromString_Success(string value)
 {
     Assert.Equal(TestType.IntegrationTest, TestType.From(value));
 }
예제 #57
0
        /// <summary>
        /// 客户端请求
        /// </summary>
        private void request()
        {
            try
            {
                sendAsyncEventArgs.SocketError = SocketError.Success;
                ulong random = AutoCSer.Random.Default.NextULong();
                this.testType = loopTestType == TestType.Random ? (TestType)((byte)random & 7) : loopTestType;
                byte[] url = urls[(byte)testType];
                System.Buffer.BlockCopy(url, 0, sendBuffer, 0, asyncSize = url.Length);
                fixed(byte *bufferFixed = sendBuffer)
                {
                    asyncSize += Number.ToString(left = (int)(uint)random, bufferFixed + asyncSize);
                    *(long *)(bufferFixed + asyncSize) = '&' + ('r' << 8) + ('i' << 16) + ('g' << 24) + ((long)'h' << 32) + ((long)'t' << 40) + ((long)'=' << 48);
                    asyncSize += 7;
                    asyncSize += Number.ToString(right = (int)(uint)(random >> 32), bufferFixed + asyncSize);
                    if (keepAliveCount == 1 || task.KeepAliveCount == 1)
                    {
                        Buffer.BlockCopy(httpVersion, 0, sendBuffer, asyncSize, httpVersion.Length);
                        asyncSize += httpVersion.Length;
                    }
                    else
                    {
                        Buffer.BlockCopy(httpVersionKeepAlive, 0, sendBuffer, asyncSize, httpVersionKeepAlive.Length);
                        asyncSize += httpVersionKeepAlive.Length;
                    }
                    switch (testType)
                    {
                    case TestType.WebView:
                    case TestType.WebViewAsynchronous:
                        Buffer.BlockCopy(AutoCSerSpiderUserAgent, 0, sendBuffer, asyncSize, AutoCSerSpiderUserAgent.Length);
                        asyncSize += AutoCSerSpiderUserAgent.Length;
                        break;
                    }
                    *(short *)(bufferFixed + asyncSize) = 0x0a0d;
                }
                asyncSize += sizeof(short);
                if (keepAliveCount == 0)
                {
                    asyncType = ClientSocketAsyncType.Connect;
                    socket    = new Socket(serverEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
#if !MONO
                    socket.SendBufferSize = socket.ReceiveBufferSize = bufferSize;
#endif
                    socket.LingerState = lingerOption;
                    keepAliveCount     = task.KeepAliveCount - 1;
                    sendAsyncEventArgs.SetBuffer(0, asyncSize);
                    if (socket.ConnectAsync(sendAsyncEventArgs))
                    {
                        return;
                    }
                    if (sendAsyncEventArgs.SocketError == SocketError.Success)
                    {
                        if (sendAsyncEventArgs.BytesTransferred == 0 ? send() : receive())
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (send())
                    {
                        return;
                    }
                }
            }
            catch (Exception error)
            {
                Console.WriteLine(error.ToString());
            }
            onError();
        }
예제 #58
0
 public void ConvertSecurityTestStringToTestType_Success()
 {
     Assert.Equal(TestType.SecurityTest, TestType.From("@securitytest"));
 }
예제 #59
0
        /// <summary>
        /// Creates test result
        /// </summary>
        /// <param name="executionId"></param>
        /// <param name="parentExecutionId"></param>
        /// <param name="testType"></param>
        /// <param name="testElement"></param>
        /// <param name="parentTestElement"></param>
        /// <param name="parentTestResult"></param>
        /// <param name="rocksteadyTestResult"></param>
        /// <returns>Trx test result</returns>
        private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, TestType testType,
                                             ITestElement testElement, ITestElement parentTestElement, ITestResult parentTestResult, ObjectModel.TestResult rocksteadyTestResult)
        {
            // Create test result
            TrxLoggerObjectModel.TestOutcome testOutcome = this.converter.ToOutcome(rocksteadyTestResult.Outcome);
            var testResult = this.converter.ToTestResult(testElement.Id.Id, executionId, parentExecutionId, testElement.Name,
                                                         this.testResultsDirPath, testType, testElement.CategoryId, testOutcome, this.testRun, rocksteadyTestResult);

            // Normal result scenario
            if (parentTestResult == null)
            {
                this.results.TryAdd(executionId, testResult);
                return(testResult);
            }

            // Ordered test inner result scenario
            if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType))
            {
                (parentTestResult as TestResultAggregation).InnerResults.Add(testResult);
                this.innerResults.TryAdd(executionId, testResult);
                return(testResult);
            }

            // Data driven inner result scenario
            if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.UnitTestType))
            {
                (parentTestResult as TestResultAggregation).InnerResults.Add(testResult);
                testResult.DataRowInfo      = (parentTestResult as TestResultAggregation).InnerResults.Count;
                testResult.ResultType       = TrxLoggerConstants.InnerDataDrivenResultType;
                parentTestResult.ResultType = TrxLoggerConstants.ParentDataDrivenResultType;
                return(testResult);
            }

            return(testResult);
        }
예제 #60
0
 public void ConvertSecurityTestFromEnum_Success(TestType.Enumeration value)
 {
     Assert.Equal(TestType.SecurityTest, TestType.From(value));
 }