Esempio n. 1
0
        public static void HaveSamePropertiesAs(this FluentAssertions.Primitives.ObjectAssertions actual, object expexted, IEnumerable <string> properties = null)
        {
            var type = actual.Subject.GetType();

            if (type != expexted.GetType())
            {
                throw new ArgumentException("Object types must be the same.");
            }
            properties = properties ?? type.GetProperties().Select(x => x.ToString());
            foreach (var prop in properties.Select(type.GetProperty))
            {
                prop.GetValue(actual.Subject).Should().Be(prop.GetValue(expexted));
            }
        }
Esempio n. 2
0
        public static void HaveSameFieldsAs(this FluentAssertions.Primitives.ObjectAssertions actual, object expexted, IEnumerable <string> fields = null)
        {
            var type = actual.Subject.GetType();

            if (type != expexted.GetType())
            {
                throw new ArgumentException("Object types must be the same.");
            }
            fields = fields ?? type.GetFields().Select(x => x.ToString());
            foreach (var field in fields.Select(type.GetField))
            {
                field.GetValue(actual.Subject).Should().Be(field.GetValue(expexted));
            }
        }