wekempf / testify Goto Github PK
View Code? Open in Web Editor NEW.NET unit test helper framework.
License: Apache License 2.0
.NET unit test helper framework.
License: Apache License 2.0
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.
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.
Foo foo = new Foo();
Assert.IsTrue(foo.CompareTo(null) > 0);
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
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.