void EntityIsMissingRequiredMember_PublicField() { var memberRequiredComponent = new MemberRequiredComponent(new object(), new object()) { PublicProp = new object(), PublicField = null }; var memberName = nameof(memberRequiredComponent.PublicField); TestSingle(memberRequiredComponent, memberName); }
void EntityIsMissingRequiredMember_ProtectedProp() { var memberRequiredComponent = new MemberRequiredComponent(new object(), null) { PublicProp = new object(), PublicField = new object() }; var memberName = "ProtectedProp"; TestSingle(memberRequiredComponent, memberName); }
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); }); }
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); }
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); }