Exemplo n.º 1
0
        private static string DescriptionOf(ISelfDescribing selfDescribing)
        {
            TextWriter writer = new DescriptionWriter();

            selfDescribing.DescribeTo(writer);
            return(writer.ToString());
        }
Exemplo n.º 2
0
        private static string DescriptionOf(ISelfDescribing selfDescribing)
        {
            var writer = new StringDescriptionWriter();

            selfDescribing.DescribeOn(writer);
            return writer.ToString();
        }
Exemplo n.º 3
0
        private bool InternalTryMatch(Object actual, IMatcher childMatcher, ISelfDescribing selfDescribing)
        {
            //so we can print child diagnostics after
            var childDiag = new MatchDiagnostics();
            var matched   = childMatcher.Matches(actual, childDiag);

            Text(matched ? "Match":"Mismatch!");

            var desc = Description.With();

            if (selfDescribing != null)
            {
                desc.Value(selfDescribing);
            }
            if (!matched)
            {
                Expect.PrintExpectButGot(desc, actual, childMatcher);
                desc.Value(childDiag);
            }
            else
            {
                desc.Value(childMatcher);
            }
            Child(desc);
            return(matched);
        }
Exemplo n.º 4
0
        public static void ShouldHaveDescription(this ISelfDescribing matcher, IMatcher <string> expectedMatcher)
        {
            var description = new StringDescription();

            matcher.DescribeTo(description);
            var actual = description.ToString();

            Assert.That(actual, expectedMatcher);
        }
Exemplo n.º 5
0
        private static void WriteExpected(ISelfDescribing matcher, TextWriter writer)
        {
            writer.Write(TextMessageWriter.Pfx_Expected);
            var description = new StringDescription();

            matcher.DescribeTo(description);
            writer.Write(description.ToString());
            writer.WriteLine();
        }
Exemplo n.º 6
0
        public static void ShouldHaveDescription(this ISelfDescribing matcher, string expected)
        {
            var description = new StringDescription();

            matcher.DescribeTo(description);
            var actual = description.ToString();

            Xunit.Assert.Equal(expected, actual);
        }
Exemplo n.º 7
0
        public static void IsComposed(ISelfDescribing selfDescribing, string format, params ISelfDescribing[] components)
        {
            var componentDescriptions = new string[components.Length];
            for (int i = 0; i < components.Length; i++)
            {
                componentDescriptions[i] = DescriptionOf(components[i]);
            }

            IsEqual(selfDescribing, String.Format(format, componentDescriptions));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the name of the member to be used as the name for a mock returned an a call to a stub.
        /// </summary>
        /// <param name="invocation">The invocation.</param>
        /// <returns>Name of the mock created as a result value on a call to a stub.</returns>
        private string GetMemberName(ISelfDescribing invocation)
        {
            var writer = new StringWriter();

            invocation.DescribeTo(writer);

            var name = writer.ToString();

            return(name.Replace(Environment.NewLine, string.Empty));
        }
Exemplo n.º 9
0
        public static void IsComposed(ISelfDescribing selfDescribing, string format, params ISelfDescribing[] components)
        {
            string[] componentDescriptions = new string[components.Length];
            for (int i = 0; i < components.Length; i++)
            {
                componentDescriptions[i] = DescriptionOf(components[i]);
            }

            IsEqual(selfDescribing, String.Format(format, componentDescriptions));
        }
        private static MicroModelObject CreateMicroModelObject(ISelfDescribing selfDescribing)
        {
            selfDescribing.SealTypeDescription();

            var properties           = selfDescribing.GetProperties();
            var microModelObjectType = MicroModelObjectBuilder.GetMicroModelObjectType(properties);

            var microModelObject = (MicroModelObject)Activator.CreateInstance(microModelObjectType, selfDescribing);

            return(microModelObject);
        }
Exemplo n.º 11
0
 public static void IsEqual(ISelfDescribing selfDescribing, string expectedDescription)
 {
     Assert.AreEqual(expectedDescription, DescriptionOf(selfDescribing), "description");
 }
Exemplo n.º 12
0
 public ModelTypeDescriptor(ISelfDescribing model)
 {
     _model = model;
 }
Exemplo n.º 13
0
 public IMatchDiagnostics MisMatched(ISelfDescribing selfDescribing)
 {
     return(this);
 }
Exemplo n.º 14
0
 public bool TryMatch(Object actual, IMatcher childMatcher, ISelfDescribing selfDescribing)
 {
     return(InternalTryMatch(actual, childMatcher));
 }
Exemplo n.º 15
0
 public bool TryMatch <T>(T actual, IMatcher <T> childMatcher, ISelfDescribing selfDescribing)
 {
     return(InternalTryMatch(actual, childMatcher));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Return the description of an <see cref="ISelfDescribing"/> object as a string.
 /// </summary>
 /// <param name="selfDescribing">The object to be described.</param>
 /// <returns>The description of the object.</returns>
 public static string ToString(ISelfDescribing selfDescribing)
 {
     return new StringDescription().AppendDescriptionOf(selfDescribing).ToString();
 }
Exemplo n.º 17
0
 public static void IsEqual(ISelfDescribing selfDescribing, string expectedDescription)
 {
     Assert.AreEqual(expectedDescription, DescriptionOf(selfDescribing), "description");
 }
Exemplo n.º 18
0
 /// <summary>
 /// Alias for ToString(ISelfDescribing).
 /// </summary>
 public static String AsString(ISelfDescribing selfDescribing)
 {
     return(ToString(selfDescribing));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Return the description of an <see cref="ISelfDescribing"/> object as a string.
 /// </summary>
 /// <param name="selfDescribing">The object to be described.</param>
 /// <returns>The description of the object.</returns>
 public static string ToString(ISelfDescribing selfDescribing)
 {
     return(new StringDescription().AppendDescriptionOf(selfDescribing).ToString());
 }
Exemplo n.º 20
0
 /// <summary>
 /// Alias for ToString(ISelfDescribing).
 /// </summary>
 public static String AsString(ISelfDescribing selfDescribing)
 {
     return ToString(selfDescribing);
 }
Exemplo n.º 21
0
 public IMatchDiagnostics Matched(ISelfDescribing selfDescribing)
 {
     Text("Match");
     Child(selfDescribing);
     return(this);
 }
Exemplo n.º 22
0
 public IDescription AppendDescriptionOf(ISelfDescribing value)
 {
     return(this);
 }
Exemplo n.º 23
0
		/// <summary>
		/// Gets the name of the member to be used as the name for a mock returned an a call to a stub.
		/// </summary>
		/// <param name="invocation">The invocation.</param>
		/// <returns>Name of the mock created as a result value on a call to a stub.</returns>
		private string GetMemberName(ISelfDescribing invocation)
		{
			var writer = new StringWriter();
			invocation.DescribeTo(writer);

			var name = writer.ToString();
			return name.Replace(Environment.NewLine, string.Empty);
		}