public void ConstructorOk()
        {
            var mockCodeElement = MockRepository.GenerateStub <ICodeElementInfo>();
            var context         = new ContractVerificationContext(mockCodeElement);

            Assert.AreSame(mockCodeElement, context.CodeElement);
        }
        private static IEnumerable <Test> GetContractVerificationTests(IContract contract, IFieldInfo field)
        {
            var context = new ContractVerificationContext(field);

            return(contract.GetContractVerificationTests(context));
        }
 /// <inheritdoc />
 public IEnumerable <Test> GetContractVerificationTests(ContractVerificationContext context)
 {
     this.Context = context;
     return(GetContractVerificationTests());
 }
        private static void VerifyMemberTypes(Type type, ICollection <Type> visitedTypes, ContractVerificationContext context)
        {
            if (!visitedTypes.Contains(type))
            {
                visitedTypes.Add(type);

                foreach (var fieldInfo in type.GetFields(FieldBindingFlags))
                {
                    AssertionHelper.Explain(() =>
                                            Assert.IsTrue(fieldInfo.IsInitOnly),
                                            innerFailures => new AssertionFailureBuilder("Expected the field to be marked as read only since it is part of an immutable type.")
                                            .AddRawLabeledValue("Declaring Type", fieldInfo.DeclaringType)
                                            .AddRawLabeledValue("Field Type", fieldInfo.FieldType)
                                            .AddRawLabeledValue("Field Name", fieldInfo.Name)
                                            .SetStackTrace(context.GetStackTraceData())
                                            .AddInnerFailures(innerFailures)
                                            .ToAssertionFailure());

                    VerifyMemberTypes(fieldInfo.FieldType, visitedTypes, context);
                }
            }
        }