public static void Main(String[] args) {
 Environment.ExitCode = 1; 
 bool bResult = true;
 Console.WriteLine("ReflectionInsensitiveLookup: Test using reflection to do case-insensitive lookup with high chars.");
 TestClass tc = new TestClass();
 Assembly currAssembly = tc.GetType().Module.Assembly;
 String typeName = tc.GetType().FullName;
 Type tNormal = currAssembly.GetType(typeName);
 if (tNormal!=null) {
 Console.WriteLine("Found expected type.");
 } else {
 bResult = false;
 Console.WriteLine("Unable to load expected type.");
 }
 Type tInsensitive = currAssembly.GetType(typeName, false, true);
 if (tInsensitive!=null) {
 Console.WriteLine("Found expected insensitive type.");
 } else {	
 bResult = false;
 Console.WriteLine("Unable to load expected insensitive type.");
 }
 if (bResult) {
 Environment.ExitCode = 0;
 Console.WriteLine("Passed!");
 } else {
 Console.WriteLine("Failed!");
 }
 }
		public void Init()
		{
			IProject project = new MockCSharpProject();
			project.Name = "TestProject";
			ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
			nunitFrameworkReferenceItem.Include = "NUnit.Framework";
			ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);

			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture");
			mockClass.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(mockClass);
			
			// Add a method to the test class
			MockMethod mockMethod = new MockMethod(mockClass, "TestMethod1");
			mockMethod.Attributes.Add(new MockAttribute("Test"));
			mockClass.Methods.Add(mockMethod);
			
			mockMethod = new MockMethod(mockClass, "TestMethod2");
			mockMethod.Attributes.Add(new MockAttribute("Test"));
			mockClass.Methods.Add(mockMethod);
			
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testProject = new TestProject(project, projectContent, testFrameworks);
			testClass = testProject.TestClasses[0];
			testMethod1 = testClass.TestMembers[0];
			testMethod2 = testClass.TestMembers[1];
		}
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method GetEnumerator in ValueCollection Generic IEnumerable 2");
     try
     {
         Dictionary<TestClass, TestClass> dic = new Dictionary<TestClass, TestClass>();
         TestClass TKey1 = new TestClass();
         TestClass TVal1 = new TestClass();
         TestClass TKey2 = new TestClass();
         TestClass TVal2 = new TestClass();
         dic.Add(TKey1, TVal1);
         dic.Add(TKey2, TVal2);
         IEnumerable<TestClass> ienumer = (IEnumerable<TestClass>)new Dictionary<TestClass, TestClass>.ValueCollection(dic);
         IEnumerator<TestClass> ienumerator = ienumer.GetEnumerator();
         Dictionary<TestClass, TestClass>.Enumerator dicEnumer = dic.GetEnumerator();
         while (ienumerator.MoveNext() && dicEnumer.MoveNext())
         {
             if (!ienumerator.Current.Equals(dicEnumer.Current.Value))
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpecResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #4
0
 public static void Main(string[] args)
 {
     TestClass tc = new TestClass ();
     tc.testclass();
     tc.Print ();
     tc.Display ();
 }
 private static IEnumerable<Trace> Log(
     TestClass original, 
     TestClass current)
 {
     return new AuditTrails()
         .Log(original, current);
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("Return the property get_Current in the IEnumerator 2");
     try
     {
         Dictionary<TestClass, TestClass> dictionary = new Dictionary<TestClass, TestClass>();
         TestClass Tkey1 = new TestClass();
         TestClass TVal1 = new TestClass();
         dictionary.Add(Tkey1, TVal1);
         Dictionary<TestClass, TestClass>.Enumerator enumer = dictionary.GetEnumerator();
         IEnumerator iEnumer = (IEnumerator)enumer;
         while(iEnumer.MoveNext())
         {
             object objCurrent = iEnumer.Current;
             KeyValuePair<TestClass, TestClass> keyVal = new KeyValuePair<TestClass, TestClass>(Tkey1, TVal1);
             if (!objCurrent.Equals(keyVal))
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #7
0
		public static TestClass singletonInstance()
		{
			if (TestClass.instance == null)
				TestClass.instance = new TestClass();

			return TestClass.instance;
		}
Example #8
0
        public void TestMapperShallow()
        {
            var c = new TestClass
            {
                Name = "Jordan",
                Others = new List<OtherClass>
                {
                    new OtherClass
                    {
                        Name = "Other 1"
                    },
                    new OtherClass
                    {
                        Name = "Other 2"
                    }
                }
            };

            var c2 = new TestClass();


            c.CopyProperties(c2);

            Assert.IsTrue(c2.Name == c.Name);
            Assert.IsTrue(object.ReferenceEquals(c2.Others, c.Others));
        }
Example #9
0
    public void TestDumpClassNoTypeHint()
    {
        var testClass = new TestClass() { x = 5, y = 7, z = 0 };
        testClass.list = new List<int>() { { 3 }, { 1 }, { 4 } };

        Assert.AreEqual( "{\"x\":5,\"y\":7,\"list\":[3,1,4]}", JSON.Dump( testClass, EncodeOptions.NoTypeHints ) );
    }
Example #10
0
 private void runTest_Click(object sender, EventArgs e)
 {
     TestClass test = new TestClass();
     var result = test.Test();
     //var result = test.Read(new Guid("6242395E-B14A-4F9E-B95C-FEEF425E9860"));
     resultLbl.Text = result.ClientId.ToString();
 }
Example #11
0
 private static int Main()
 {
     TestClass _this = new TestClass();
     if (!Test_NEWOBJ(_this, 0, true))
     {
         Console.WriteLine("Failed => 101");
         return 101;
     }
     if (!Test_NEWOBJ(_this, 1, true))
     {
         Console.WriteLine("Failed => 102");
         return 102;
     }
     if (!Test_NEWOBJ(_this, 2, false))
     {
         Console.WriteLine("Failed => 103");
         return 103;
     }
     if (!Test_NEWOBJ(_this, 3, false))
     {
         Console.WriteLine("Failed => 104");
         return 104;
     }
     Console.WriteLine("Passed => 100");
     return 100;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("Invoke the method Reset in the KeyCollection IEnumerator 2");
     try
     {
         Dictionary<TestClass, TestClass> dic = new Dictionary<TestClass, TestClass>();
         TestClass Tkey1 = new TestClass();
         TestClass TVal1 = new TestClass();
         dic.Add(Tkey1,TVal1);
         IEnumerator keycollectIEnumer = (IEnumerator)new Dictionary<TestClass, TestClass>.KeyCollection(dic).GetEnumerator();
         while (keycollectIEnumer.MoveNext()) { }
         keycollectIEnumer.Reset();
         if (keycollectIEnumer.MoveNext())
         {
             if (!keycollectIEnumer.Current.Equals(Tkey1))
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("----- Main AppDomain -----");
            var control = new TestClass();
            control.DoWork();
            Console.WriteLine("Int: {0}", control.ReturnIntResult());
            Console.WriteLine("Complex A: {0} B: {1}", control.ReturnComplexResult().A, control.ReturnComplexResult().B);

            Console.WriteLine();
            Console.WriteLine("----- New AppDomain -----");
            AppDomain newDomain = AppDomain.CreateDomain("TestDomain");
            newDomain.UnhandledException += new UnhandledExceptionEventHandler(newDomain_UnhandledException);

            string assembly = typeof(TestClass).Assembly.FullName;
            string type = typeof(TestClass).FullName;

            var handle = newDomain.CreateInstance(assembly, type);
            TestClass secondary = handle.Unwrap() as TestClass;
            Console.WriteLine("Int: {0}", secondary.ReturnIntResult());
            Console.WriteLine("Complex A: {0} B: {1}", secondary.ReturnComplexResult().A, secondary.ReturnComplexResult().B);

            try
            {
                secondary.ThrowException();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Example #14
0
        public static int Main( string[] astrArguments )
        {
            TestClass tc = new TestClass();
            int nType = 1;
            if ( astrArguments.Length > 0 )
                nType = Convert.ToInt32( astrArguments[ 0 ] );

            switch ( nType )
            {
                case 1:
                    new TestClass1().Run();
                    break;
                case 2:
                    new TestClass2().Run();
                    break;
                case 3:
                    new TestClass3().Run();
                    break;
                default:
                    Console.WriteLine( "Unknown test: " + nType );
                    break;
            }

            return 0;
        }
Example #15
0
        public static void Main(string[] args)
        {
            //var test = ReflectionGetter.GetFields(typeof(TestClass));
            //var properties = ReflectionGetter.GetProperties(typeof(TestClass));

            var temp = new TestClass()
            {
                Test1 = "Test1String",
                Test2 = 2,
                Test3 = 2.5,
                Test4 = "Test4String",
                TestSub = new TestSubClass() { TestSub = "TestSub", TestSub2 = new TestSubClass2() { TestSub3 = "TestSub3"} }
            };

            var testList = ReflectionConvert.SerializeToDictionary<TestClass>(temp);
            foreach(var val in testList)
            {
                Console.WriteLine(val.Key + ":" + val.Value.Value);
            }

            /*
            var methods = ReflectionGetter.GetMethods(typeof(TestClass));

            foreach(var val in test)
            {
                Console.WriteLine(val.Name + ":" + val.Type.Name + ":" + val.ReflectedType.Name);
            }

            foreach (var val in properties)
            {
                Console.WriteLine(val.Name + ":" + val.Type.Name + ":" + val.ReflectedType.Name);
            }*/

            Console.ReadLine();
        }
Example #16
0
 public static bool InterfaceTest3()
 {
     TestClass tc = new TestClass();
     IInterfaceAB b = tc;
     bool result = (b.A() == 2);
     return result;
 }
Example #17
0
        private static int Main(string[] args)
        {
            TestClass t = new TestClass();
            List<TestClass.LongStruct> x = t.Test();

            return (x.Count == 1) ? 100 : 101;
        }
Example #18
0
	public static void Main(string[] args)
	{
		Colours myColour = Colours.Green | Colours.Blue;
		TestClass testClass = new TestClass();
		testClass.TestFun(543, "asdf");
		Fun1();
	}
		public void Init()
		{	
			// Add a test class.
			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			MockClass c = new MockClass("RootNamespace.MyTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			c.ProjectContent = projectContent;
			projectContent.Classes.Add(c);
			
			// Add first method.
			MockMethod method = new MockMethod("MyTest");
			method.Attributes.Add(new MockAttribute("Test"));
			method.DeclaringType = c;
			c.Methods.Add(method);
			
			// Add duplicate method.
			c.Methods.Add(method);
			
			// Add a base class that has duplicate methods.
			MockClass baseClass = new MockClass("RootNamespace.MyTestFixtureBase");
			baseClass.Attributes.Add(new MockAttribute("TestFixture"));
			baseClass.ProjectContent = projectContent;
			projectContent.Classes.Add(baseClass);
			c.BaseClass = baseClass;
			baseClass.Methods.Add(method);
			baseClass.Methods.Add(method);
			
			// Create test class.
			testClass = new TestClass(c);
		}
Example #20
0
  /// <summary>
  /// Tests the caching and re using of sessiosn to increase perfomance by avoding
  /// creating new sessions for each client request
  /// </summary>
 // [Test]
  public void CachedSessionTest()
  {
      ServerClientSession lSession = GetCachedSession();
      //lets simulate that we did some prior work, return the session and get it again
      ReturnSessionToCache(lSession);
      lSession = GetCachedSession();
      TestClass lTestClass = new TestClass();
      lTestClass.SomeIntVar = 123;
      lTestClass.SomeStringVar = "test";
      lTestClass.Persist(lSession, lTestClass);
      lSession.Commit();
      //return to cache, get it again and query the object
      //as this test is to verify it does not hang we do it in separate therad and kill after timeout
      ReturnSessionToCache(lSession);
      Thread lThread=new Thread(new ThreadStart(()=>
      {
          lSession = GetCachedSession();
          counter = lSession.AllObjects<TestClass>(true, false).Count();
          ReturnSessionToCache(lSession);
      }));
      lThread.Start();
      lEvent.WaitOne(5000);
      if(lThread.IsAlive)lThread.Abort();
      Assert.AreNotEqual(0, counter, "Invalid nr of objects retreived");
  }
Example #21
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest1()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest1: Remove a function from the delegate which contains only 1 callback function");
            try
            {
                DelegateRemoveImpl delctor = new DelegateRemoveImpl();
                TestClass tcInstance = new TestClass();
                delctor.starkWork = new booldelegate(tcInstance.StartWork_Bool);
                delctor.starkWork -= new booldelegate(tcInstance.StartWork_Bool);
                if (null != delctor.starkWork)
                {
                    TestLibrary.TestFramework.LogError("001", "remove failure  " );
                    retVal = false;
                }
                
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
                retVal = false;
            }
            
            return retVal;
        }
        public void CombineClass()
        {
            var prev = new TestClass()
            {
                PString = "prev",
                FString1 = "prev",
                FString2 = "prev",
                FInt = 1,
                NInt = 0,
                Array1 = new int[]{1, 2, 3},
                Array2 = new int[]{1, 2, 3}
            };

            var next = new TestClass()
            {
                PString = "next",
                FString1 = "next",
                FString2 = null,
                FInt = 0,
                NInt = null,
                Array1 = null,
                Array2 = new int[]{3, 3, 3}
            };

            var result = _combiner.Combine(prev, next);

            Assert.That(result.PString, Is.EqualTo("next"));
            Assert.That(result.FString1, Is.EqualTo("next"));
            Assert.That(result.FString2, Is.EqualTo("prev"));
            Assert.That(result.FInt, Is.EqualTo(1));
            Assert.That(result.NInt, Is.EqualTo(0));
            Assert.That(result.Array1, Is.EquivalentTo(new int[] { 1, 2, 3 }));
            Assert.That(result.Array2, Is.EquivalentTo(new int[] { 3, 3, 3 }));
        }
        public void Should_work_same_way_as_memory_stream_on_read()
        {
            var serializer = new JsonSerializer();

            var origin = new TestClass
            {
                Name = "FFasdf fasd  FASDfas   fadsfa  dafsdf  asdf a fsd ",
                CreatedAt = DateTime.Now,
                IsObsolete = true,
                Count = 31241325351
            };
            using (var writer = new JsonTextWriter(new StreamWriter(_ethalonStream)))
            {
                serializer.Serialize(writer, origin);
            }

            _testStream.ChangeBuffer(_ethalonBuffer);

            using (var reader = new JsonTextReader(new StreamReader(_testStream)))
            {
                var reburnished = serializer.Deserialize<TestClass>(reader);

                Assert.That(reburnished.Name, Is.EqualTo(origin.Name));
                Assert.That(reburnished.CreatedAt, Is.EqualTo(origin.CreatedAt));
                Assert.That(reburnished.IsObsolete, Is.EqualTo(origin.IsObsolete));
                Assert.That(reburnished.Count, Is.EqualTo(origin.Count));
            }
        }
Example #24
0
        public IEnumerable<object> GetTestCases()
        {
            yield return new CETData() { Description = "box null to int?", Expression = Expression.Convert(Expression.Constant(null), typeof(int?)), ExpectedValue = null };
            yield return new CETData() { Description = "box enum to int?", Expression = Expression.Convert(Expression.Constant(TestEnum.Foo), typeof(int?)), ExpectedValue = 3 };
            yield return new CETData() { Description = "box null to enum? to int?", Expression = Expression.Convert(Expression.Convert(Expression.Constant(null), typeof(TestEnum?)), typeof(int?)), ExpectedValue = null };
            yield return new CETData() { Description = "convert enum? null to int?", Expression = Expression.Convert(Expression.Constant((TestEnum?)null), typeof(int?)), ExpectedValue = null };

            yield return new CETData() { Description = "add int", Expression = Expression.Add(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = 3 };
            yield return new CETData() { Description = "add int to null", Expression = Expression.Add(Expression.Constant(1, typeof(int?)), Expression.Constant(null, typeof(int?))), ExpectedValue = null };
            yield return new CETData() { Description = "add int? to int?", Expression = Expression.Add(Expression.Constant(1, typeof(int?)), Expression.Constant(2, typeof(int?))), ExpectedValue = 3 };
            yield return new CETData() { Description = "bitwise and", Expression = Expression.And(Expression.Constant(1, typeof(int?)), Expression.Constant(3, typeof(int?))), ExpectedValue = 0x1 };
            yield return new CETData() { Description = "logical and", Expression = Expression.AndAlso(Expression.Constant(true), Expression.Constant(true)), ExpectedValue = true };
            yield return new CETData() { Description = "logical and", Expression = Expression.AndAlso(Expression.Constant(false), Expression.Constant(true)), ExpectedValue = false };
            yield return new CETData() { Description = "subtract int", Expression = Expression.Subtract(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = -1 };
            yield return new CETData() { Description = "equality int==int", Expression = Expression.Equal(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = false };
            yield return new CETData() { Description = "equality int!=int", Expression = Expression.NotEqual(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = true };

            yield return new CETData() { Description = "equality int==int?", Expression = Expression.Equal(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(2), typeof(int?))), ExpectedValue = false };
            yield return new CETData() { Description = "equality int!=int?", Expression = Expression.NotEqual(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(2), typeof(int?))), ExpectedValue = true };

            yield return new CETData() { Description = "equality int==int?null", Expression = Expression.Equal(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(null), typeof(int?))), ExpectedValue = false };
            yield return new CETData() { Description = "equality int!=int?null", Expression = Expression.NotEqual(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(null), typeof(int?))), ExpectedValue = true };

            var fieldtest = new TestClass() { field = "foo" };
            yield return new CETData() { Description = "field access", Expression = ((Expression<Func<string>>)(() => fieldtest.field)).Body, ExpectedValue = "foo" };

            var propertytest = new TestClass() { property = "foo" };
            yield return new CETData() { Description = "property access", Expression = ((Expression<Func<string>>)(() => propertytest.property)).Body, ExpectedValue = "foo" };

            yield return new CETData() { Description = "decrement int", Expression = Expression.Decrement(Expression.Constant(1)), ExpectedValue = 0 };
            yield return new CETData() { Description = "increment int", Expression = Expression.Increment(Expression.Constant(1)), ExpectedValue = 2 };
            yield return new CETData() { Description = "one's complement int", Expression = Expression.OnesComplement(Expression.Constant(1)), ExpectedValue = ~1 };
            yield return new CETData() { Description = "one's complement int", Expression = Expression.OnesComplement(Expression.Constant(-1)), ExpectedValue = ~-1 };
        }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("Return the property get_Entry in the IDictionaryEnumerator 2");
     try
     {
         Dictionary<TestClass,TestClass> dictionary = new Dictionary<TestClass,TestClass>();
         TestClass Tkey1 = new TestClass();
         TestClass TVal1 = new TestClass();
         dictionary.Add(Tkey1,TVal1);
         Dictionary<TestClass,TestClass>.Enumerator enumer = dictionary.GetEnumerator();
         IDictionaryEnumerator idicEnumer = (IDictionaryEnumerator)enumer;
         if (idicEnumer.MoveNext())
         {
             DictionaryEntry entryVal = idicEnumer.Entry;
             if (entryVal.Key != Tkey1 || entryVal.Value != TVal1)
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #26
0
 public OnExitTests()
 {
     t = new TestClass();
     Monitor.Enter (sync);
     execInfo.Clear();
     execInfo2.Clear();
 }
        public void Write_WritesDataTypes_ToUnderlyingStream_WhenNotBuffering()
        {
            // Arrange
            var expected = new[] { "True", "3", "18446744073709551615", "Hello world", "3.14", "2.718" };
            var unbufferedWriter = new Mock<TextWriter>();
            unbufferedWriter.SetupGet(w => w.Encoding).Returns(Encoding.UTF8);
            var buffer = new ViewBuffer(new TestViewBufferScope(), "some-name");
            var writer = new RazorTextWriter(unbufferedWriter.Object, buffer, new HtmlTestEncoder());
            var testClass = new TestClass();

            // Act
            writer.Flush();
            writer.Write(true);
            writer.Write(3);
            writer.Write(ulong.MaxValue);
            writer.Write(testClass);
            writer.Write(3.14);
            writer.Write(2.718m);

            // Assert
            Assert.Null(buffer.BufferSegments);
            foreach (var item in expected)
            {
                unbufferedWriter.Verify(v => v.Write(item), Times.Once());
            }
        }
		protected void InitBase()
		{			
			projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			// Create the base test class.
			outerClass = new MockClass(projectContent, "MyTests.A");
			projectContent.Classes.Add(outerClass);
			
			// Create the inner test class.
			// Note the use of the DotNetName "MyTests.A+InnerTest".
			innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
			innerClass.Attributes.Add(new MockAttribute("TestFixture"));

			MockMethod method = new MockMethod(innerClass, "FooBar");
			method.Attributes.Add(new MockAttribute("Test"));
			innerClass.Methods.Add(method);
			outerClass.InnerClasses.Add(innerClass);
			
			// Add another inner class that is not a test class.
			nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass);
			outerClass.InnerClasses.Add(nonTestInnerClass);

			// Add another inner class with the same name as the InnerATest.
			// This makes sure duplicate classes are not added.
			MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
			duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			outerClass.InnerClasses.Add(duplicateInnerClass);
			
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testProject = new TestProject(null, projectContent, testFrameworks);
			if (testProject.TestClasses.Count > 0) {
				testClass = testProject.TestClasses[0];
			}
		}
Example #29
0
    private static void Main(string[] args)
    {
        //        var sm = new SDSkillManager();
        //        var s = sm.GetAllSkills();
        //        foreach (var skill in s)
        //        {
        //            Console.WriteLine($"Skill id : {skill.ID}\n");
        //            skill.SetCurrentPlayerLevel(0);
        //            Console.WriteLine($"Skill can not be used... : {skill.CanBeUsed()}\n");
        //            skill.SetCurrentPlayerLevel(5);
        //            Console.WriteLine($"Skill can be used... : {skill.CanBeUsed()}\n");
        //            skill.TryActivateSkill();
        //            skill.TryActivateSkill(); // Should not run because of cooldown
        //            Console.WriteLine($"{skill.Name} is running : {skill.IsInUse} \n");
        //            Console.WriteLine($"{skill.Name} can be blocked? : {skill.CanBeBlocked} \n");
        //            Console.WriteLine($"{skill.Name} setting it to can be blocked\n");
        //            skill.CanBeBlocked = true;
        //            Console.WriteLine($"{skill.Name} can be blocked? : {skill.CanBeBlocked} \n");
        //            Console.WriteLine($"{skill.Name} is blocked? : {skill.IsBlocked} \n");
        //            Console.WriteLine($"{skill.Name} blocking it\n");
        //            skill.IsBlocked = true;
        //            Console.WriteLine($"{skill.Name} is blocked? : {skill.IsBlocked} \n");
        //            Console.WriteLine($"{skill.Name} trying activate blocked skill... Was it successfull : {skill.TryActivateSkill()}\n");
        //            Console.WriteLine($"{skill.Name} Immediate activation of blocked skill!!" +
        //                              $" Banzaiiii!! : {skill.ActivateSkillImmediately()}\n");
        //            Console.WriteLine($"{skill.Name} unblocking it\n");
        //            skill.IsBlocked = false;
        //        }
        //        Console.ReadKey();

        // Create methods
        //        var t0 = new FwTimer(1f);
        //        var t1 = new FwTimer();
        //        var t2 = new FwTimer(10, TimerType.Inverted);
        //        var t4 = new FwTimer(2, TimerType.Inverted, TimerLogStatus.Disabled);
        //        t4.Start();
        //        t4.Pause();
        //        t4.TimePassed();
        //        t4.TimeLeft();
        //        t4.TimeIncrease(1f);
        //        t4.TimeDecrease(1.0);

        FwTimer timer = new FwTimer(3000);
        TestClass tc = new TestClass();
        timer.Elapsed += tc.OnEndOne;
        timer.Elapsed += tc.OnEndTwo;
        Console.WriteLine("Launching timer");
        timer.Start();
        Console.WriteLine("Timer launched");
           // Console.ReadKey();

        FwTimer timer2 = new FwTimer() {IntervalSeconds = 3};
        TestClass tc2 = new TestClass();
        timer2.Elapsed += tc2.OnEndOne;
        timer2.Elapsed += tc2.OnEndTwo;
        Console.WriteLine("Launching timer");
        timer.Start();
        Console.WriteLine("Timer launched");
           // Console.ReadKey();
    }
 public void CanUseRefFieldAndVariableClosures()
 {
     var x = new TestClass();
     Expression<Func<object, string>> expected = o => "" + x + instanceTestClass;
     Func<object, string> compiled = o => "" + x + instanceTestClass;
     Test(expected, compiled);
 }
Example #31
0
 public void Execute(TestClass testClass)
 => throw new Exception("Unsafe custom execution threw!");
Example #32
0
 /// <summary>Defaultni konstruktor pro <see cref="Driver"/></summary>
 /// <param name="testClass">Testovací třída, která Driver inicializuje</param>
 public Driver(TestClass testClass)
 {
     TestClass = testClass;
 }
Example #33
0
        public void Test_getter_performance()
        {
            var test = new TestClass()
            {
                Value = "Hallo"
            };

            var    stopwatch = new Stopwatch();
            object a;

            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                var accessor = (typeof(TestClass).GetProperty("Value"));

                a = accessor.GetValue(test);//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - propertyinfo");

            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                var accessor = PropertyInfoHelper.GetAccessor(typeof(TestClass).GetProperty("Value"));

                a = accessor.GetValue(test);//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - accessor");

            var cachedAccessor = PropertyInfoHelper.GetAccessor(typeof(TestClass).GetProperty("Value"));
            var accessorCache  = new Dictionary <string, IPropertyAccessor>()
            {
                { "Value", cachedAccessor }
            };

            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                var accessor = accessorCache["Value"];

                a = accessor.GetValue(test);//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - cached accessor");

            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                var accessor = TypeHelpers.GetPropertyAccessor(typeof(TestClass), "Value");

                a = accessor.GetValue(test);//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - typehelper");


            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                a = test.Value;//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - direct");

            stopwatch.Restart();
            for (var i = 0; i < 100000; i++)
            {
                var accessor = FastMember.TypeAccessor.Create(typeof(TestClass));

                a = accessor[test, "Value"];//.Should().Be("Hallo");
            }

            stopwatch.Stop();
            Debug.WriteLine($"{stopwatch.ElapsedMilliseconds}ms - fastmember");
        }
Example #34
0
 public void Setup()
 {
     _model = new TestClass();
 }
Example #35
0
        public void TestGetValue()
        {
            var dataTable = new DataTable();

            dataTable.Columns.Add("Column", typeof(int));
            dataTable.Rows.Add(1);

            TestClass2  dataItem1 = new TestClass2();
            DataRow     dataItem2 = dataTable.Rows[0];
            IDataReader dataItem3 = Substitute.For <IDataReader>();
            TestClass   dataItem4 = new TestClass();

            var hierarchicalDataItem = new HierarchicalDataItem
            {
                Value  = dataItem4,
                Parent = new HierarchicalDataItem
                {
                    Value  = dataItem1,
                    Parent = new HierarchicalDataItem
                    {
                        Value  = dataItem2,
                        Parent = new HierarchicalDataItem
                        {
                            Value = dataItem3,
                        }
                    }
                }
            };

            var factory = Substitute.For <IDataItemValueProviderFactory>();
            var objectPropertyValueProvider = Substitute.For <ObjectPropertyValueProvider>();
            var dataRowValueProvider        = Substitute.For <DataRowValueProvider>();
            var dataReaderValueProvider     = Substitute.For <DataReaderValueProvider>();
            var dataItemValueProvider       = new DefaultDataItemValueProvider(factory)
            {
                DataItemSelfTemplate = "di"
            };

            factory.Create(null).Returns(objectPropertyValueProvider);
            factory.Create(dataItem1).Returns(objectPropertyValueProvider);
            factory.Create(dataItem2).Returns(dataRowValueProvider);
            factory.Create(dataItem3).Returns(dataReaderValueProvider);
            factory.Create(dataItem4).Returns(objectPropertyValueProvider);

            ExceptionAssert.Throws <ArgumentException>(() => dataItemValueProvider.GetValue(null, hierarchicalDataItem));
            ExceptionAssert.Throws <ArgumentException>(() => dataItemValueProvider.GetValue(string.Empty, hierarchicalDataItem));
            ExceptionAssert.Throws <ArgumentException>(() => dataItemValueProvider.GetValue(" ", hierarchicalDataItem));

            ExceptionAssert.Throws <ArgumentNullException>(() => dataItemValueProvider.GetValue("Template", null));
            ExceptionAssert.Throws <ArgumentNullException>(() => dataItemValueProvider.GetValue("Template", null));
            ExceptionAssert.Throws <ArgumentNullException>(() => dataItemValueProvider.GetValue("Template", null));

            objectPropertyValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("di", hierarchicalDataItem);
            objectPropertyValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            dataItemValueProvider.GetValue("Prop", hierarchicalDataItem);
            objectPropertyValueProvider.Received(1).GetValue("Prop", dataItem4);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            dataItemValueProvider.DataItemSelfTemplate = "dataItem";
            objectPropertyValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("parent:dataItem", hierarchicalDataItem);
            objectPropertyValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            dataItemValueProvider.GetValue("parent:Prop", hierarchicalDataItem);
            objectPropertyValueProvider.Received(1).GetValue("Prop", dataItem1);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            objectPropertyValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("parent:parent", hierarchicalDataItem);
            objectPropertyValueProvider.Received(1).GetValue("parent", dataItem1);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            objectPropertyValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("parent : PARENT: Column", hierarchicalDataItem);
            objectPropertyValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataRowValueProvider.Received(1).GetValue("Column", dataItem2);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            dataRowValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("parent : PARENT :parent:Column", hierarchicalDataItem);
            objectPropertyValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.Received(1).GetValue("Column", dataItem3);

            hierarchicalDataItem.Value = null;
            dataReaderValueProvider.ClearReceivedCalls();
            dataItemValueProvider.GetValue("Prop", hierarchicalDataItem);
            objectPropertyValueProvider.Received(1).GetValue("Prop", null);
            dataRowValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);
            dataReaderValueProvider.DidNotReceiveWithAnyArgs().GetValue(null, null);

            ExceptionAssert.Throws <InvalidTemplateException>(() => dataItemValueProvider.GetValue("par:Prop", hierarchicalDataItem), "Template \"par:Prop\" is invalid");
        }
Example #36
0
 static void Main(string[] args)
 {
     TestClass test = new TestClass();
 }
Example #37
0
 public override void TestInitialize()
 {
     base.TestInitialize();
     Obj = new TestClass();
 }
Example #38
0
 public bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace)
 {
     return(true);
 }
Example #39
0
 public WhenBuildingTheObject_WithProvidedDateTime()
 {
     _result = Sut.With(x => x.DateTimeProperty, _providedDateTime).build();
 }
Example #40
0
 public WhenBuildingTheObject_WithProvidedInteger()
 {
     _result = Sut.With(x => x.IntegerProperty, _providedInteger).build();
 }
Example #41
0
 public WhenBuildingTheObject_WithProvidedValueUsingHaving()
 {
     _result = Sut.Having(x => x.StringProperty, _providedString).build();
 }
Example #42
0
 public WhenBuildingTheObject()
 {
     _result = Sut.build();
 }
Example #43
0
        public void Discount_Negative_Total()
        {
            TestClass test = new TestClass();

            test.TestCllas(-1);
        }
Example #44
0
        public void GetOnly()
        {
            var o = new TestClass();

            o.GetOnly.ShouldBe("foobar");
        }
Example #45
0
        public void GuardExpressions_WhenExpressionContainsAnyProperty_ValidationFailure_ShouldWorkAsExpected()
        {
            TestClass testClassInstance = new TestClass();

            Guard.AgainstNull(() => testClassInstance.TestStringNullProperty);
        }
Example #46
0
        public void GuardExpressions_AgainstInvalidType_ShouldFail_WhenTypeInvalid()
        {
            TestClass testClassInstance = new TestClass();

            Guard.AgainstInvalidType <string>(() => testClassInstance, "testClassInstance is not a string.");
        }
Example #47
0
        public void GuardExpressions_AgainstInvalidType_ShouldSucceed_WhenTypeIsDerivedFromRequiredType()
        {
            TestClass testClassInstance = new TestClass();

            TestParentClass result = Guard.AgainstInvalidType <TestParentClass>(() => testClassInstance, "testClassInstance is is derived from TestParentClass, the check should succeed.");
        }
Example #48
0
        public void GuardExpressions_AgainstInvalidType_ShouldSucceed_WhenTypeImplementsReuiredInterface()
        {
            TestClass testClassInstance = new TestClass();

            ITestInterface result = Guard.AgainstInvalidType <ITestInterface>(() => testClassInstance, "testClassInstance implements ITestInterface, the test should succeed.");
        }
Example #49
0
        public void StaticSumParameters()
        {
            var value = TestClass.StaticSum(1, 2, 3, 4);

            value.ShouldBe(10);
        }
Example #50
0
        public void GuardExpressions_AgainstInvalidType_ShouldSucceed_WhenTypeIsExactMatch()
        {
            TestClass testClassInstance = new TestClass();

            TestClass result = Guard.AgainstInvalidType <TestClass>(() => testClassInstance);
        }
    public static int Main(string[] a)
    {
        try
        {
            int S = Sum(5, 12.0, 6, 13.0f, __arglist());
            if (S == 36)
            {
                Console.WriteLine("Test 1 passed");
            }
            else
            {
                Console.WriteLine("Test 1 failed !! Ret: " + S);
                return(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("Test failed " + e);
            return(1);
        }
        try
        {
            MyStruct st;
            st.x = 123;
            st.y = 434;
            int S = Sum(3, 1.0, 2, 8.0f, __arglist(5, st, "aaa", 6));

            if (S == 1573)
            {
                Console.WriteLine("Test 2 passed");
            }
            else
            {
                Console.WriteLine("Test 2 failed !! Ret: " + S);
                return(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("Test failed " + e);
            return(1);
        }
        try
        {
            TestClass A = new TestClass();
            int       S = A.Sub(9, 7, __arglist());

            if (S == 2)
            {
                Console.WriteLine("Test 3 passed");
            }
            else
            {
                Console.WriteLine("Test 3 failed !! Ret: " + S);
                return(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("Test failed " + e);
            return(1);
        }

        try
        {
            TestClass A = new TestClass();
            Struct1   s1;
            s1.x = 43;
            MyStruct S = A.SumAndCount(9, 7, __arglist(3, 4, 5, (byte)34, (short)45,
                                                       (long)123456789123456789L, (int)1, (long)123456789123456789L, (float)432, s1, (double)42));

            if (S.x == 627 && S.y == 11)
            {
                Console.WriteLine("Test 4 passed");
            }
            else
            {
                Console.WriteLine("Test 4 failed !! Ret: " + S.x + " " + S.y);
                return(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("Test failed " + e);
            return(1);
        }

        try
        {
            long sum = EnumTest(__arglist(
                                    Enum1.EnumName1, Enum1.EnumName2, Enum8.EnumName8, Enum16.EnumName16,
                                    Enuml.EnumNamel, Enum8.EnumName8, Enuml.EnumNamel));

            if (sum == 246913578246926186)
            {
                Console.WriteLine("Test 5 passed");
            }
            else
            {
                Console.WriteLine("Test 5 failed !! Ret: " + sum);
                return(1);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Test failed " + e);
            return(1);
        }

        return(0);
    }
Example #52
0
 public void Execute(TestClass testClass)
 {
     //Class lifecycle chooses not to invoke testClass.RunCases(...).
     //Since the test cases never run, they are all considered
     //'skipped'.
 }
Example #53
0
 public void Static_Void_NoArguments() {
     var method = Info.MethodOf(() => TestClass.StaticVoidNoArguments());
     Assert.Same(method, typeof(TestClass).GetMethod("StaticVoidNoArguments"));
 }
Example #54
0
 public static TestClass EchoTestObject(TestClass value)
 {
     return(value);
 }
Example #55
0
        void AssertTestClassFound(string name)
        {
            TestClass c = GetTestClass(name);

            Assert.IsTrue(c != null);
        }
    public void ifs(long w)
    {
        int  x = 0;
        long y = 50;

        use(y);
        use(w);

        if (x > 0)
        {
            y = 20;
            use(y);
        }
        else
        {
            y = 30;
            w = 10;
            use(w);
        }

        use(y);
        use(w);

        if (x < 0)
        {
            y = 40;
            w = 20;
        }
        else
        {
            return;
        }

        use(y);
        use(w);

        if (x == 0)
        {
            y = 60;
        }

        use(y);

        var z = x;

        use(z);

        outMethod(out z);
        use(z);

        refMethod(ref z);
        use(z);

        Field = w;
        use(Field);

        Prop = x;
        use(Prop);

        int i = 0;

        System.Action act = () => { i = 1; };
        use(i);

        Field2 = 0;
        use(Field2);

        Field3 = 0;
        TestClass tc = null;

        tc.Field3 = 1;
        use(Field3);

        i = 0;
        i++;
        use(i);

        i = 0;
        i--;
        use(i);

        var x1 = 0;

        while (refMethod(ref x1) && Field2 > 0)
        {
        }
        use(x1);

        var x2 = 0;

        refOutMethod(
            ref x2,
            out x2);
        use(x2);

        var x3 = 0;
        int x4;

        refOutMethod(
            ref x3,
            out x4);
        use(x3);
        use(x4);

        var x5 = 0;

        while (x5 > 10)
        {
            use(x5);
            x5 = x5 + 1;
        }

        x5 += 1;
        use(x5);

        return;
    }
Example #57
0
 public void ClassStaticMethods()
 {
     Assert.AreEqual("jeb", TestClass.StaticMethod(Connection));
     Assert.AreEqual("jebbobbill", TestClass.StaticMethod(Connection, "bob", "bill"));
 }
Example #58
0
 private void OnTestClassReceived(TestClass obj) => Console.WriteLine($"RECEIVED FROM SERVER: {obj.Text}");
Example #59
0
 public abstract void UnresolvedGenericInstanceTypeMethod(TestClass <T> unresolved);
Example #60
0
 static int Main()
 {
     return(TestClass.GetZero());
 }