/// <summary>
        /// Generates the concurrency token attribute.
        /// </summary>
        /// <param name="memberProperty">The property.</param>
        /// <returns>Generated attribute</returns>
        protected override XAttribute GenerateConcurrencyToken(MemberProperty memberProperty)
        {
            ConcurrencyTokenAnnotation annotation = memberProperty.Annotations.OfType <ConcurrencyTokenAnnotation>().SingleOrDefault();

            if (annotation == null)
            {
                return(null);
            }

            return(new XAttribute("ConcurrencyMode", "Fixed"));
        }
        private void CompareMemberProperty(MemberProperty expectedProperty, MemberProperty actualProperty)
        {
            this.CompareMemberPropertyDatatype(expectedProperty.Name, expectedProperty.PropertyType, actualProperty.PropertyType);

            this.WriteErrorIfFalse(expectedProperty.IsPrimaryKey == actualProperty.IsPrimaryKey, "Expected '{0}' for IsPrimaryKey of property '{1}' but got '{2}'", expectedProperty.IsPrimaryKey, expectedProperty.Name, actualProperty.IsPrimaryKey);

            ConcurrencyTokenAnnotation concurrencyToken = expectedProperty.Annotations.OfType <ConcurrencyTokenAnnotation>().FirstOrDefault();

            if (concurrencyToken != null)
            {
                this.WriteErrorIfFalse(expectedProperty.Annotations.Any(), "Expected property '{0}' to have a concurrencyTokenAnnotation", expectedProperty.Name);
            }
        }
Example #3
0
        private void CompareMemberProperty(MemberProperty expectedProperty, MemberProperty actualProperty)
        {
            this.SatisfiesEquals(expectedProperty.Name, actualProperty.Name, "Property name does not match.");
            this.SatisfiesEquals(expectedProperty.IsPrimaryKey, actualProperty.IsPrimaryKey, "IsPrimaryKey of property '{0}' does not match.", expectedProperty.Name);

            this.CompareDataType(expectedProperty.PropertyType, actualProperty.PropertyType, "Property " + expectedProperty.Name);

            ConcurrencyTokenAnnotation expectedConcurrencyToken = expectedProperty.Annotations.OfType <ConcurrencyTokenAnnotation>().SingleOrDefault();
            ConcurrencyTokenAnnotation actualConcurrencyToken   = actualProperty.Annotations.OfType <ConcurrencyTokenAnnotation>().SingleOrDefault();

            if (expectedConcurrencyToken != null)
            {
                this.SatisfiesCondition(actualConcurrencyToken != null, "Expected property '{0}' to be a concurrencyToken", expectedProperty.Name);
            }
            else
            {
                this.SatisfiesCondition(actualConcurrencyToken == null, "Expected property '{0}' to be NOT a concurrencyToken", expectedProperty.Name);
            }
        }