public void IsOpenInEditorError_returns_true_for_unrecoverable_errors_if_additional_conditions_not_met()
        {
            SetupModelAndInvokeAction(
                null, null, null,
                (mockModelManager, mockArtifactSet) =>
            {
                var artifact = mockArtifactSet.Object.GetEntityDesignArtifact();

                var mockEfObject = new Mock <EFObject>(null, new XElement("dummy"));
                mockEfObject.Setup(m => m.Artifact).Returns(artifact);

                var unrecoverableErrorCodes =
                    UnrecoverableRuntimeErrors
                    .SchemaObjectModelErrorCodes.Cast <int>()
                    .Concat(UnrecoverableRuntimeErrors.StorageMappingErrorCodes.Cast <int>());

                foreach (var errorCode in unrecoverableErrorCodes)
                {
                    var error = new ErrorInfo(
                        ErrorInfo.Severity.ERROR, null, mockEfObject.Object, errorCode, ErrorClass.Runtime_CSDL);

                    Assert.True(RuntimeMetadataValidator.IsOpenInEditorError(error, artifact));
                }
            });
        }
        private static bool IsOpenInEditorError <T>(int errorCode) where T : EFObject
        {
            var openInEditor = true;

            SetupModelAndInvokeAction(
                null, null, null,
                (mockModelManager, mockArtifactSet) =>
            {
                var artifact = mockArtifactSet.Object.GetEntityDesignArtifact();

                var mockEfObject =
                    new Mock <T>(null, new XElement("dummy"));
                mockEfObject.Setup(m => m.Artifact).Returns(artifact);

                Mock.Get(artifact)
                .Setup(m => m.FindEFObjectForLineAndColumn(It.IsAny <int>(), It.IsAny <int>()))
                .Returns(mockEfObject.Object);

                var error = new ErrorInfo(
                    ErrorInfo.Severity.ERROR, null, mockEfObject.Object,
                    errorCode, ErrorClass.Runtime_CSDL);

                openInEditor = RuntimeMetadataValidator.IsOpenInEditorError(error, artifact);
            });

            return(openInEditor);
        }
 public void IsOpenInEditorError_returns_false_for_non_runtime_errors()
 {
     SetupModelAndInvokeAction(
         null, null, null,
         (mockModelManager, mockArtifactSet) =>
     {
         var error = new ErrorInfo(
             ErrorInfo.Severity.ERROR, null, mockArtifactSet.Object.GetEntityDesignArtifact(),
             42, ErrorClass.ParseError);
         Assert.False(
             RuntimeMetadataValidator.IsOpenInEditorError(error, mockArtifactSet.Object.Artifacts.First()));
     });
 }