public void TestStaticClasses() { Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3)); Assert.That(TestStaticClass.OneTwoThree, Is.EqualTo(123)); Assert.That(TestStaticClassDerived.Foo(), Is.EqualTo(0)); TestNotStaticClass.StaticFunction(); }
public void UnloadNotLoadObj() { onDestroyResult = string.Empty; var c = MakeDriver(); var obj = new TestStaticClass(); c.Detach(obj); Assert.AreEqual(string.Empty, onDestroyResult); }
public void UnloadNotLoadObj() { onDestroyResult = string.Empty; var c = MakeDriver(); var d = c.Make <IMonoDriver>() as CatLib.MonoDriver.MonoDriver; var obj = new TestStaticClass(); d.Detach(obj); Assert.AreEqual(string.Empty, onDestroyResult); }
public void TestStaticClasses() { Type staticClassType = typeof(TestStaticClass); // Only static class can be both abstract and sealed Assert.IsTrue(staticClassType.IsAbstract && staticClassType.IsSealed); Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3)); Assert.That(TestStaticClass.OneTwoThree, Is.EqualTo(123)); Assert.That(TestStaticClassDerived.Foo, Is.EqualTo(0)); TestNotStaticClass.StaticFunction.GetHashCode(); }
/// "Smoke" tests for flapigen dotnet backend. /// Note, that some function does not return anything. They are called here just to verify, that there are no crashes. public void TestAll() { TestStaticClass.Hello(); TestStaticClass.PrintNumber(123); Assert.Equal(3, TestStaticClass.Add(1, 2)); Assert.Equal("Concatenated String", TestStaticClass.Concat("Concatenated ", "String")); Assert.Equal("Concatenated str", TestStaticClass.Concat("Concatenated ", "str")); var obj = new TestClass(); Assert.Equal(0, obj.Get()); obj.Increment(); Assert.Equal(1, obj.Get()); obj.Add(3); obj.Print(); Assert.Equal(4, obj.Get()); TestStaticClass.TestObjByValue(obj); var vec = new List <int>(); vec.Add(1); vec.Add(2); TestStaticClass.PrintVecLen(vec); var new_vec = TestStaticClass.GetVec(); Assert.Equal(3, new_vec.Count); Assert.Equal(5, new_vec[0]); Assert.Equal(6, new_vec[1]); Assert.Equal(7, new_vec[2]); Assert.Equal(0, TestStaticClass.MaybeReturnClass(new Option <string>("asdf")).Value.Get()); Assert.False(TestStaticClass.MaybeAddOne(new Option <int>()).IsSome); // This shouldn't throw. TestStaticClass.TryCreateObjectOk(); // But this one should. Assert.Throws <flapigen_test_dotnet.Error>(() => TestStaticClass.TryCreateObjectErr()); var arc_mutex = new TestArcMutex(); arc_mutex.Inc(); Assert.Equal("1", arc_mutex.ToString()); Assert.Equal("1", TestArcMutex.ToStringArc(arc_mutex)); Assert.Equal(TestEnum.A, TestStaticClass.ReverseEnum(TestEnum.B)); var tuple = TestStaticClass.GetTuple(); Assert.Equal(0, tuple.Item1); Assert.Equal("0", tuple.Item2); }
public void TestGenericSetupDefaultNegativeIncorrectExpression() { var body = Expression.Block( Expression.Add(Expression.Constant(1), Expression.Constant(2)), Expression.Constant(3)); var lambda = Expression.Lambda <Action>(body); Assert.Throws <Exception>(() => Mock.SetupDefault(lambda, () => { TestStaticClass.TestMethodReturn1WithoutParameters(); })); }
public void RepeatLoadTest() { var c = MakeDriver(); var obj = new TestStaticClass(); c.Attach(obj); ExceptionAssert.Throws <RuntimeException>(() => { c.Attach(obj); }); }
public void TestNestedThrowsMockWithDifferentFunctionsParentAfterChild() { Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { Mock.Setup(() => TestStaticClass.TestMethodReturnWithParameter(2), () => { Assert.Throws <ArgumentNullException>(() => TestStaticClass.TestMethodReturnWithParameter(2)); }).Throws(typeof(ArgumentNullException)); Assert.Throws <Exception>(() => TestStaticClass.TestMethodReturn1WithoutParameters()); }).Throws(typeof(Exception)); }
public void ThePropertiesShouldBeCopied() { dynamic person = new { Name = "Chris", Age = 42, }; TestStaticClass result = DynamicToStatic.ToStatic <TestStaticClass>(person); result.ShouldHave().AllPropertiesBut(@class => @class.Birthday).EqualTo(person); }
public void OnDestroyTest() { var c = MakeDriver(); var obj = new TestStaticClass(); c.Attach(obj); updateResult = string.Empty; c.OnDestroy(); c.Update(); Assert.AreEqual(string.Empty, updateResult); }
public async Task TestSetupReturnsMethodsReturnTaskAsync() { var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(); Assert.AreEqual(1, originalResult); var expectedResult = 2; Mock.Setup(typeof(TestStaticClass), nameof(TestStaticClass.TestMethodReturnTaskWithoutParametersAsync), async() => { var actualResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(); Assert.AreEqual(expectedResult, actualResult); }).Returns(Task.FromResult(expectedResult)); }
public void RepeatLoadTest() { var c = MakeDriver(); var d = c.Make <IMonoDriver>() as CatLib.MonoDriver.MonoDriver; var obj = new TestStaticClass(); d.Attach(obj); ExceptionAssert.Throws <RuntimeException>(() => { d.Attach(obj); }); }
public async Task TestGenericSetupReturnsAsyncMethodsReturnTaskAsync() { var originalResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(); Assert.AreEqual(1, originalResult); var expectedResult = 2; Mock.Setup(() => TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(), async() => { var actualResult = await TestStaticClass.TestMethodReturnTaskWithoutParametersAsync(); Assert.AreEqual(expectedResult, actualResult); }).ReturnsAsync(expectedResult); }
public void TestNestedThrowsReturnTest() { const int expectedChildResult = 2; Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { Assert.Throws <Exception>(() => TestStaticClass.TestMethodReturn1WithoutParameters()); Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { var actualChildResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedChildResult, actualChildResult); }).Returns(expectedChildResult); }).Throws <Exception>(); }
public void OnDestroyTest() { var c = MakeDriver(); var d = c.Make <IMonoDriver>() as CatLib.MonoDriver.MonoDriver; var obj = new TestStaticClass(); d.Attach(obj); updateResult = string.Empty; d.OnDestroy(); d.Update(); Assert.AreEqual(string.Empty, updateResult); }
public void TestGenericSetupReturnsWithTestMethodReturn1WithoutParameters() { var originalResult = TestStaticClass.TestMethodReturn1WithoutParameters(); var expectedResult = 2; Mock.Setup( () => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { var actualResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreNotEqual(originalResult, actualResult); Assert.AreEqual(expectedResult, actualResult); }) .Returns(expectedResult); }
public void TestNestedInChildCallbackMockWithDifferentFunctions() { const int expectedParentResult = 2; const int expectedChildResult = 3; Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { Mock.Setup(() => TestStaticClass.TestMethodReturnWithParameter(2), () => { var actualChildResult = TestStaticClass.TestMethodReturnWithParameter(2); Assert.AreEqual(expectedChildResult, actualChildResult); var actualParentResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedParentResult, actualParentResult); }).Callback(() => expectedChildResult); }).Callback(() => expectedParentResult); }
public void TestNestedInChildReturnThrowsMockWithDifferentFunctions() { const int expectedParentResult = 2; Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { Mock.Setup(() => TestStaticClass.TestMethodReturnWithParameter(2), () => { var actualParentResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedParentResult, actualParentResult); Assert.Throws <Exception>(() => TestStaticClass.TestMethodReturnWithParameter(2)); actualParentResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedParentResult, actualParentResult); }).Throws <Exception>(); }).Returns(expectedParentResult); }
public void TestNestedReturnMock() { const int expectedParentResult = 2; const int expectedChildResult = 3; Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { var actualParentResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedParentResult, actualParentResult); Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { var actualChildResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedChildResult, actualChildResult); }).Returns(expectedChildResult); }).Returns(expectedParentResult); }
public void TestReturnsWithTestMethodOutParameter() { var originalResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _); var expectedResult = 2; Mock.Setup( typeof(TestStaticClass), nameof(TestStaticClass.TestMethodReturn1WithOutParameter), () => { var actualResult = TestStaticClass.TestMethodReturn1WithOutParameter(out _); Assert.AreNotEqual(originalResult, actualResult); Assert.AreEqual(expectedResult, actualResult); }) .Returns(expectedResult); }
public void TestFuncCallback() { var originalResult = TestStaticClass.TestMethodReturn1WithoutParameters(); var expectedResult = 2; Assert.AreNotEqual(expectedResult, originalResult); Mock.Setup(typeof(TestStaticClass), nameof(TestStaticClass.TestMethodReturn1WithoutParameters), () => { var actualResult = TestStaticClass.TestMethodReturn1WithoutParameters(); Assert.AreEqual(expectedResult, actualResult); }).Callback(() => { var x = expectedResult; return(x); }); }
public static int StartTest(string info) { DebugHelper.InitLog(true); Debug.LogError(" == 223 中午 == +-*x&!@$#$()_+<>?{}|ff ~ " + info); TestStaticClass.StartTest(1); var obj = GameObject.CreatePrimitive(PrimitiveType.Sphere); //obj.AddComponent<TestDelegate>(); obj.AddComponent <TestLoader>(); obj.AddComponent <TestBehaviourScript>(); //obj.AddComponent<TestException>(); return(123); }
public void TestGenericSetupReturnsWithTestMethodReturnInstanceObject() { var originalResult = TestStaticClass.TestMethodReturnReferenceObject(); var expectedResult = new TestInstance { IntProperty = 1, ObjectProperty = new object() }; Mock.Setup( () => TestStaticClass.TestMethodReturnReferenceObject(), () => { var actualResult = TestStaticClass.TestMethodReturnReferenceObject(); Assert.AreNotEqual(originalResult, actualResult); Assert.AreEqual(expectedResult, actualResult); }) .Returns(expectedResult); }
static void StartTest() { var ptr = ScriptEngine.GetFuncPointer(); MonoBind.InitBind(ptr); DebugHelper.InitLog(true); Debug.LogError(" ========223 中午 ==== +-*x&!@$#$()_+<>?{}|ff ~"); TestStaticClass.StartTest(1); TestCube(); var obj = GameObject.CreatePrimitive(PrimitiveType.Sphere); //obj.AddComponent<TestDelegate>(); obj.AddComponent <TestLoader>(); obj.AddComponent <TestBehaviourScript>(); //obj.AddComponent<TestException>(); }
public void TestStaticClasses() { Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3)); }
public void TestGenericSetup() { Mock.Setup(() => TestStaticClass.TestMethodReturn1WithoutParameters(), () => { }); }
public void OnEntry_Called_For_StaticMethod_In_StaticClass() { TestStaticClass.StaticMethod(); Assert.True(callsBag.Contains("StaticClass_StaticMethod")); }
public void TestStaticClasses() { Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3)); Assert.That(TestStaticClassDerived.Foo(), Is.EqualTo(0)); }