public void Should_create_object_without_default_constructor() { var fake = Fake.Create <MyClassWithCtorArgs>(); var instance = fake.Generate(); Assert.AreNotEqual(string.Empty, instance.Foo); Assert.IsNotNull(instance.Foo); }
public void Should_use_internal_Fake_for_property() { var fake1 = Fake.Create <MyFoo>().SetProperty(x => x.NumberOfBeers, () => 0).SetProperty(x => x.Sqrt, () => - 1.0d); var fake2 = Fake.Create <MyBar>(fake1); Assert.True(fake2.Generate(1000).All(x => x.Foo1.NumberOfBeers == x.Foo2.NumberOfBeers && x.Foo1.NumberOfBeers == 0)); Assert.True(fake2.Generate(1000).All(x => x.Foo1.Sqrt == x.Foo2.Sqrt && x.Foo1.Sqrt == -1.0d)); }
public void Should_shuffle_array() { var randomIntegers = Fake.Create <int>().Generate(100); var shuffled = randomIntegers.Shuffle().ToList(); Assert.AreEqual(randomIntegers.Count, shuffled.Count); Assert.False(randomIntegers.SequenceEqual(shuffled)); var hashset1 = new HashSet <int>(randomIntegers); var hashset2 = new HashSet <int>(shuffled); Assert.True(hashset1.SetEquals(hashset2)); }