Beispiel #1
0
        public void TestWaitForPageToBeActiveCallsNativeInterfaceNoActionIfMissing()
        {
            var targetClass = new InheritedClass();
            var target      = new TestBase(targetClass);

            target.WaitForPageToBeActive();
        }
 // Start is called before the first frame update
 void Start()
 {
     inheritedClass  = new InheritedClass();
     genericClassInt = new GenericClass <int>();
     Debug.Log($"The generic class singleton is null: {GenericClass<int>.singletonInstance == null}");
     Debug.Log($"The generic class singleton is null: {InheritedClass.singletonInstance == null}");
     Debug.Log($"The generic class instance field is: {genericClassInt.instanceField}");
 }
Beispiel #3
0
        public void Access(InheritedClass inheritedClass)
        {
            inheritedClass.PublicMember             = "Access OK";
            inheritedClass._internalMember          = "Access OK"; //Наследует ClassForInheritance
            inheritedClass._protectedInternalMember = "Access OK"; //Наследует ClassForInheritance

            //inheritedClass._protectedMember = "Access False"; доступен только внутри класса
            //inheritedClass._privateProtectedMember = "Access False"; доступен только внутри класса
            //inheritedClass._privateMember = "Access False"; доступен только внутри класса
        }
        public void CanInvokeInheritedMethod()
        {
            IUnityContainer container = new UnityContainer()
                                        .RegisterType <InheritedClass>(
                new InjectionMethod("InjectMe"));

            InheritedClass result = container.Resolve <InheritedClass>();

            Assert.IsTrue(result.WasInjected);
        }
    public Task Inherited()
    {
        var target = new InheritedClass
        {
            Value = "line1"
        };
        var settings = new VerifySettings();

        settings.UseExtension("txt");
        return(Verifier.Verify(target, settings));
    }
Beispiel #6
0
        public void CanCopyInheritedProperties()
        {
            var c = new InheritedClass();

            c.IntProp    = 2;
            c.StringProp = "string";
            var newC = c.ShallowCopy();

            Assert.Equal(c.IntProp, newC.IntProp);
            Assert.Equal(c.StringProp, newC.StringProp);
        }
Beispiel #7
0
        public static uint CMPInterfaceImplementationInherited()
        {
            InheritedClass instance = new InheritedClass();

            if (instance.TestFunction() == 10)
            {
                return(1);
            }

            return(0);
        }
Beispiel #8
0
    static void Main(string[] args)
    {
        var inherited = new InheritedClass();
        var parent    = inherited as ParentClass;
        var d         = parent as dynamic;

        parent.foo();
        inherited.foo();
        d.foo();
        parent.bar();
        inherited.bar();
        d.bar();
        Console.Read();
    }
Beispiel #9
0
        public void InheritBasic()
        {
            string         lua    = GetLua();
            InheritedClass result = Serializer.Deserialize <InheritedClass>(lua);

            Assert.AreEqual(1, result.BaseProp);
            Assert.AreEqual(2, result.BaseField);
            Assert.AreEqual(3, result.InheritedProp);
            Assert.AreEqual(4, result.InheritedField);

            string serializeString = Serializer.Serialize(result);

            Assert.AreEqual("{[\"InheritedProp\"]=3,[\"BaseProp\"]=1,[\"InheritedField\"]=4,[\"BaseField\"]=2,}", serializeString);
        }
        public void GetHashCode_should_return_different_value_for_changed_property_in_base_class()
        {
            var instance = new InheritedClass();

            instance.A = 1;
            instance.B = 2;

            var firstResult = instance.GetHashCode();

            instance.A = 3;
            var secondResult = instance.GetHashCode();

            Assert.NotEqual(firstResult, secondResult);
        }
Beispiel #11
0
        public void TestSetPropertySetsPropertyValue()
        {
            var page   = new InheritedClass();
            var target = new TestBase(page);

            IPropertyData data;
            var           result = target.TryGetProperty("Name", out data);

            Assert.AreEqual(true, result);

            // Set the property value via the action
            data.FillData("Dan");

            Assert.AreEqual("Dan", page.Name);
        }
Beispiel #12
0
        public void TestCallElementInvoker()
        {
            var page = new InheritedClass {
                Button = new BaseElement()
            };

            var target = new TestBase(page);

            IPropertyData property;
            var           result = target.TryGetProperty("Button", out property);

            property.ClickElement();

            Assert.IsTrue(result);
        }
            public void GetValueTest()
            {
                // Get value by path.
                const string testString = "test";
                MainClass    test       = new MainClass(testString);

                Assert.Equal(testString, test.GetValue("Sub.SubSub.Value"));

                // Get value of non-existing path.
                Assert.Throws <ArgumentException>(() => test.GetValue("NonExisting"));

                // Values from base types in inherited types.
                InheritedClass inherited = new InheritedClass(testString);

                Assert.Equal(testString, inherited.GetValue("Sub.SubSub.Value"));
            }
        public void Equals_should_return_false_for_different_value_for_changed_property_in_base_class()
        {
            var first = new InheritedClass();

            first.A = 1;
            first.B = 2;

            var second = new InheritedClass();

            second.A = 3;
            second.B = 2;

            var result = first.Equals(second);

            Assert.False(result);
        }
        public void InitializeOnlyOnceTest()
        {
            var oneConstructor = new InitializeOnlyOnce(1);

            Assert.AreEqual(1, oneConstructor.GetActionInitializedCount());

            var multipleConstructors = new InitializeOnlyOnce();

            Assert.AreEqual(1, multipleConstructors.GetActionInitializedCount());

            var inherited = new InheritedClass();

            Assert.AreEqual(1, inherited.GetActionInitializedCount());
            var inherited2 = new InheritedClass();

            Assert.AreEqual(1, inherited2.GetStaticInitializedCount());
        }
Beispiel #16
0
    public Task Inherited()
    {
        VerifierSettings.RegisterFileConverter <ParentClass>(
            (instance, _) =>
        {
            var streams = ToStream(instance.Value);
            return(new ConversionResult(null, streams.Select(x => new ConversionStream("txt", x))));
        });

        var target = new InheritedClass
        {
            Value = "line1"
        };
        var settings = new VerifySettings();

        settings.UseExtension("txt");
        return(Verifier.Verify(target, settings));
    }
Beispiel #17
0
        public void MoreCasting()
        {
            var inherited = new InheritedClass();

            Assert.True(inherited is DemoClass);

            // this is used if you are not sure if can be casted. Not needed as often anymore
            var tmp = inherited as DemoClass;

            Assert.NotNull(tmp);

            // This is how it is usually done
            if (inherited is DemoClass demo)
            {
                Assert.NotNull(demo);
            }
            else
            {
                throw new Exception();
            }
        }
        public void ItGeneratesInheritedCorrectPatchDocument()
        {
            var original = new InheritedClass()
            {
                Id           = "id",
                Message      = "message",
                DecimalValue = 1.43m,
                GuidValue    = Guid.Empty,
                IntList      = new List <int>()
                {
                    1, 2, 3
                },
                ExtraIntValue = 23
            };
            var modified = new InheritedClass()
            {
                Id           = "new-id",
                Message      = null,
                DecimalValue = 1.68m,
                GuidValue    = Guid.Parse("64362fd9-a24a-4b4b-97cd-8ba9df24a1b5"),
                IntList      = new List <int>()
                {
                    1, 3, 2
                },
                ExtraIntValue = 34
            };

            var generator = new JsonPatchDocumentGenerator();
            var patch     = generator.Generate(original, modified);

            // Modify original with patch.
            patch.ApplyTo(original);

            Assert.NotNull(patch);
            Assert.Equal(6, patch.Operations.Count);
            Assert.Equal(original, modified, new GenericDeepEqualityComparer <InheritedClass>());
        }
 public InheritedClass() : base()
 {
     singletonInstance = this;
 }
 public void Copy(InheritedClass inheritedClassToCopy)
 {
     base.Copy(myClassToCopy);
     //specific copy code for this extensions in this class
 }
Beispiel #21
0
        public void CanCopyInheritedProperties()
        {
            var c = new InheritedClass();
            c.IntProp = 2;
            c.StringProp = "string";
            var newC = c.ShallowCopy();

            Assert.Equal(c.IntProp, newC.IntProp);
            Assert.Equal(c.StringProp, newC.StringProp);
        }
Beispiel #22
0
		public static uint CMPInterfaceImplementationInherited ()
		{
			InheritedClass instance = new InheritedClass ();

			if (instance.TestFunction () == 10)
				return 1;

			return 0;
		}
 public void Copy(InheritedClass inheritedClassToCopy)
 {
     //copy code
 }