/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v1.8.4
src/NUnitTests/TestNullConversion.cs
254 строки
6 KB
Sergey Batanov
Восстановлена работоспособность тестов NUnit.
23 ноя 2022, 13:06
23 ноя 2022, 13:06
4da9b8b
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; using ScriptEngine.Machine; using ScriptEngine.Machine.Contexts; using NUnit.Framework; namespace NUnitTests { [ContextClass("ТестNullПреобразования", "TestNullConversion")] class TestNullConversion : AutoContext<TestNullConversion> { IValue _pIValue; string _pString; TestNullClass _pClass; public TestNullConversion() { } [ScriptConstructor(Name = "Без параметров")] public static TestNullConversion Constructor() { return new TestNullConversion(); } [ContextMethod("ТестIValue", "IValueTest")] public IValue TestIValue(IValue arg) { return arg; } [ContextMethod("ТестIValueНеопределено", "IValueNullTest")] public IValue TestIValueNull(IValue arg) { if (arg != ValueFactory.Create()) Assert.Fail("Test IValue Func(IValue) -> Func(Unknown): argument value is different from null."); return arg; } [ContextMethod("ТестКласс", "ClassTest")] public TestNullClass TestClass(TestNullClass arg) { if (arg.GetType() != typeof(TestNullClass)) Assert.Fail("Test Class Func(Class) -> Func(Class): argument type is different from Class."); return arg; } [ContextMethod("ТестClassНеопределено", "ClassNullTest")] public TestNullClass TestClassNull(TestNullClass arg) { if (arg != null) Assert.Fail("Test Class Func(Class) -> Func(Unknown): argument value is different from null."); return arg; } [ContextMethod("ТестString", "StringTest")] public string TestString(string arg) { if (arg.GetType() != typeof(System.String)) Assert.Fail("Test string Func(string) -> Func(string): argument type is different from string."); return arg; } [ContextMethod("ТестNullString", "StringNullTest")] public string TestStringNull(string arg) { if (arg != null) Assert.Fail("Test string Func(string) -> Func(Unknown): argument value is different from null."); return arg; } [ContextMethod("ТестInt", "IntTest")] public int TestInt(int arg) { return arg; } [ContextMethod("ТестUInt", "UIntTest")] public uint TestUInt(uint arg) { return arg; } [ContextMethod("ТестLong", "LongTest")] public long TestLong(long arg) { return arg; } [ContextMethod("ТестULong", "ULongTest")] public ulong TestULong(ulong arg) { return arg; } [ContextMethod("ТестDouble", "DoubleTest")] public double TestDouble(double arg) { return arg; } [ContextMethod("ТестDateTime", "DateTimeTest")] public DateTime TestDateTime(DateTime arg) { return arg; } [ContextMethod("ТестBool", "BoolTest")] public bool TestBool(bool arg) { return arg; } [ContextProperty("ПInt", "PInt")] public int PInt { get;set; } [ContextProperty("ПUint", "PUint")] public uint PUint { get;set; } [ContextProperty("ПLong", "PLong")] public long PLong { get;set; } [ContextProperty("ПUlong", "PUlong")] public ulong PUlong { get;set; } [ContextProperty("ПDouble", "PDouble")] public double PDouble { get;set; } [ContextProperty("ПDateTime", "PDateTime")] public DateTime PDateTime { get;set; } [ContextProperty("ПBool", "PBool")] public bool PBool { get;set; } [ContextProperty("ПString", "PString")] public string PString { get { return _pString; } set { if (value.GetType() != typeof(System.String)) Assert.Fail("Test string Property = string: value type is different from string."); _pString = value; } } [ContextProperty("ПNullString", "PNullString")] public string PNullString { get => _pString; set => _pString = value; } [ContextProperty("ПIValue", "PIValue")] public IValue PIValue { get => _pIValue; set => _pIValue = value; } [ContextProperty("ПNullIValue", "PNullIValue")] public IValue PNullIValue { get => _pIValue; set => _pIValue = value; } [ContextProperty("ПClass", "PClass")] public TestNullClass PClass { get => _pClass; set { if (value.GetType() != typeof(TestNullClass)) Assert.Fail("Test TestNullClass Property = TestNullClass: value type is different from TestNullClass."); _pClass = value; } } [ContextProperty("ПNullClass", "PNullClass")] public TestNullClass PNullClass { get => _pClass; set { if (value != null) Assert.Fail("Test TestNullClass Property = Unknown: value value is different from null."); _pIValue = value; } } } [ContextClass("ТестNullКласс", "TestNullClass")] public class TestNullClass : AutoContext<TestNullClass> { public TestNullClass() { } [ScriptConstructor(Name = "Без параметров")] public static TestNullClass Constructor() { return new TestNullClass(); } } }