Coder Social home page Coder Social logo

testify's People

Contributors

wekempf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

testify's Issues

Need to make it easier to create "factories" for AnonymousData

Currently the options are to let AnonymousData handle things entirely on it's own, or to provide a complete factory yourself. However, it's often the case that you just want to provide specific instructions for a few properties and allow AnonymousData to handle the rest. Some pseudo code to illustrate the idea (with no suggestion for final syntax on such a feature).

anon.RegisterWith<Person>(cfg => cfg.For(p => p.Age).Use(a => a.AnyInt(0, 100)).For(p => p.Secret).Ignore());

So, AnonymousData would create a Person and populate most of the properties as it normally would, but for Age it generates an int between 0 and 100 and it doesn't populate Secret at all.

This will make "adjusting" the generation for complex types (especially complex trees of types) much simpler.

Need to detect cycles when creating complex anonymous types.

public class Foo
{
    public Bar Bar { get; set; }
}

public class Bar
{
   public Foo Foo { get; set; }
}

…

anon.Any<Foo>(PopulateOption.Deep); // Results in an OutOfMemoryException

AnonymousData should detect cycles and react to them. Possible options, that maybe should be configurable behavior by the caller.

  1. Throw an exception that provides information about the cycle.
  2. Simply don't populate the property that causes the cycle.
  3. Populate the property with the "parent" value.

IsEqualTo<T> extension

The help says IsEqualTo will verify the 2 objects are equal. I happened to notice IsSameAs which checks to see if the objects are actually the same object by reference. So I am expecting that IsEqualTo just checks that the members of T are equal in value. What am I doing wrong or am I expecting something that I shouldn't

What I get is:

Test Name:	IsEqualToGenericTypeTesting_ShouldNotFail
...
Test Outcome:	Failed
Test Duration:	0:00:00.388

Result StackTrace:	
at Testify.Assertions.Throw(String assertionName, String assertionMessage, String userMessage, Object[] userArgs)
   at Testify.StandardAssertions.IsEqualTo[T](ActualValue`1 actualValue, T expected, String message, Object[] parameters)
   at Testify.StandardAssertions.IsEqualTo[T](ActualValue`1 actualValue, T expected)
   at ...
 in sometest.cs:line 126
Result Message:	Testify.AssertionException : IsEqualTo failed. Expected: <...TestingEqual>. Actual: <...TestingEqual>.

Here is my test:

[Fact]
        public void IsEqualToGenericTypeTesting_ShouldNotFail()
        {
            var test = new TestingEqual { SomeInt = 1, SomeInt2 = 2, SomeCustomEnum = CustomEnum.SomeValue1, SomeString = null };
            Assert(test).IsEqualTo(new TestingEqual { SomeInt = 1, SomeInt2 = 2, SomeCustomEnum = CustomEnum.SomeValue1, SomeString = null });
        }

Classes:

public class TestingEqual
    {
        public int SomeInt { get; set; }
        public int SomeInt2 { get; set; }
        public CustomEnum SomeCustomEnum { get; set; }
        public string SomeString { get; set; }        
    }

    public enum CustomEnum
    {
        SomeValue1 = 1,
        SomeValue2 = 2,
        SomeValue3 = 3
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.