Esempio n. 1
0
        void EntityIsMissingRequiredMember_PublicField()
        {
            var memberRequiredComponent = new MemberRequiredComponent(new object(), new object())
            {
                PublicProp  = new object(),
                PublicField = null
            };
            var memberName = nameof(memberRequiredComponent.PublicField);

            TestSingle(memberRequiredComponent, memberName);
        }
Esempio n. 2
0
        void EntityIsMissingRequiredMember_ProtectedProp()
        {
            var memberRequiredComponent = new MemberRequiredComponent(new object(), null)
            {
                PublicProp  = new object(),
                PublicField = new object()
            };
            var memberName = "ProtectedProp";

            TestSingle(memberRequiredComponent, memberName);
        }
Esempio n. 3
0
        private static void TestSingle(MemberRequiredComponent memberRequiredComponent, string memberName)
        {
            var entity = new Entity("Test");

            entity.Add(memberRequiredComponent);

            var check  = new RequiredMembersCheck();
            var result = new AssetCompilerResult();

            Assert.True(check.AppliesTo(memberRequiredComponent.GetType()));
            check.Check(memberRequiredComponent, entity, null, "", result);
            Assert.Collection(result.Messages, (msg) =>
            {
                Assert.Equal(Core.Diagnostics.LogMessageType.Warning, msg.Type);
                Assert.Contains(memberName, msg.Text);
            });
        }
Esempio n. 4
0
        void EntityIsNotMissingRequiredMembers()
        {
            var memberRequiredComponent = new MemberRequiredComponent(new object(), new object())
            {
                PublicProp  = new object(),
                PublicField = new object()
            };
            var entity = new Entity("test");

            entity.Add(memberRequiredComponent);

            var check  = new RequiredMembersCheck();
            var result = new AssetCompilerResult();

            Assert.True(check.AppliesTo(memberRequiredComponent.GetType()));
            check.Check(memberRequiredComponent, entity, null, "", result);
            Assert.Empty(result.Messages);
        }
Esempio n. 5
0
        void EntityIsMissingAllRequiredMembers()
        {
            var memberRequiredComponent = new MemberRequiredComponent(null, null)
            {
                PublicProp  = null,
                PublicField = null
            };
            var entity = new Entity("test");

            entity.Add(memberRequiredComponent);

            var check  = new RequiredMembersCheck();
            var result = new AssetCompilerResult();

            Assert.True(check.AppliesTo(memberRequiredComponent.GetType()));
            check.Check(memberRequiredComponent, entity, null, "", result);
            Assert.Equal(4, result.Messages.Count);
        }