public EqualityOperatorTestData()
        {
            var dataType = typeof(T);

            if (typeof(Body) == dataType)
            {
                AddTestData(
                    CreateBody(b => b.ContainingJson("some json value")),
                    CreateBody(b => b.MatchingXmlSchema("xml schema")));
            }
            else if (typeof(VerificationTimes) == dataType)
            {
                AddTestData(VerificationTimes.Once, VerificationTimes.Twice);
            }
            else if (typeof(Expectation) == dataType)
            {
                AddTestData(
                    FluentExpectationBuilder.Create(times: Times.Once, httpResponse: HttpResponse.Create(statusCode: 200)),
                    FluentExpectationBuilder.Create(HttpRequest.Create(method: "GET", path: "/test"), httpResponse: HttpResponse.Create(statusCode: 200)));
            }
            else
            {
                AddTestData(InstanceFactoryCreator.CreateDefault <T>(), InstanceFactoryCreator.CreateRandom <T>());
            }
        }
 public NotEqualData()
 {
     Add(CreateRandom(), CreateRandom());
     Add(InstanceFactoryCreator.CreateDefault <TData>(), CreateRandom());
     Add(CreateRandom(), null);
     Add(CreateRandom(), new FactAttribute());
 }
Esempio n. 3
0
        public void Equals_Should_Be_True_When_Instances_Are_Not_The_Same_Reference_But_Have_Same_Properties()
        {
            // Arrange
            var a = InstanceFactoryCreator.CreateDefault <T>();
            var b = a.DeepClone();

            // Assert
            a.Equals(b).Should().BeTrue();
        }
Esempio n. 4
0
        public void Equals_Should_Be_False_When_Instances_Have_Different_Types()
        {
            // Arrange
            var a = InstanceFactoryCreator.CreateDefault <T>();
            var b = new Regex("");

            // Assert
            a.Equals(b).Should().BeFalse();
        }
        public TData CreateRandom()
        {
            var parameterTypes = InstanceFactoryCreator.GetConstructorParameterTypes <TData>();
            var constructor    = InstanceFactoryCreator.ResolveBestConstructor <TData>();
            var parameters     = parameterTypes
                                 .Select(t =>
            {
                var fixture = new Fixture();
                var context = new SpecimenContext(fixture);
                var randomParameterValue = context.Resolve(t);
                return(randomParameterValue);
            })
                                 .ToArray();

            var instance = constructor.Invoke(parameters);

            return((TData)instance);
        }