public void TestNew() { Fixture <Student> fix = AutoFixture.For <Student>(); Student s = fix.New(); Assert.IsNotNull(s); Assert.IsNotNull(s.Name); Assert.AreNotEqual(0, s.Nr); Console.WriteLine(s); }
public void IgnorePropTest() { Fixture <Student> fix = AutoFixture .For <Student>() .Ignore <NonFixtureAttribute>(); // Não afecta propriedades anotadas com NonFixture Student s = fix.New(); Assert.AreEqual(0, s.Nr); }
public void FuncMemberExceptionTest() { Random rand = new Random(); DateTime dt = new DateTime(1970, 1, 1); Fixture <Student> fix = AutoFixture .For <Student>() .Member("Nr", () => dt.AddMonths(1)); Student s = fix.New(); }
public void TestFill() { Fixture <Student> fix = AutoFixture.For <Student>(); Student[] res = fix.Fill(7); foreach (Student s in res) { Assert.IsNotNull(s); Assert.IsNotNull(s.Name); Assert.AreNotEqual(0, s.Nr); } }
public void TestMember() { String[] expectedNames = { "Jose Calhau", "Maria Papoila", "Augusto Seabra" }; Object[] expectedNrs = { 8713, 2312, 23123, 131, 54534 }; Fixture <Student> fix = AutoFixture .For <Student>() .Member("Name", expectedNames) // Field or property with the name Name .Member("Nr", expectedNrs); // Field or property with the name Nr Student s = fix.New(); // The properties Name and Nr have one of above values CollectionAssert.Contains(expectedNames, s.Name); CollectionAssert.Contains(expectedNrs, s.Nr); }
public void TestComplexDomain() { Fixture <Classroom> fix = AutoFixture.For <Classroom>(); Classroom cr = fix.New(); Assert.AreNotEqual(0, cr.students.Length); foreach (Student s in cr.students) { Assert.IsNotNull(s); Assert.IsNotNull(s.Name); Assert.AreNotEqual(0, s.Nr); } Console.WriteLine(cr); }
public void TestNonSingleton() { Fixture <School> fixSchool = AutoFixture. For <School>(). Member("Name", "ISEL"); Fixture <Student> fix = AutoFixture. For <Student>(). Member("School", fixSchool); School s1 = fixSchool.New(); Student s2 = fix.New(); Student s3 = s2; s3.School.Name = "NoSchool"; Assert.AreNotEqual(s1.Name, s2.School.Name); }
public void NewTest() { Random rand = new Random(); DateTime dt = new DateTime(1970, 1, 1); Fixture <Student> fix = AutoFixture .For <Student>() .Member("BirthDate", () => dt.AddMonths(1)); Student s = fix.New(); Assert.IsNotNull(s); Assert.IsNotNull(s.Name); Assert.AreNotEqual(0, s.Nr); Assert.AreEqual(s.BirthDate, new DateTime(1970, 2, 1)); Console.WriteLine(s); }
public void IEnumerablePropTest() { Random rand = new Random(); DateTime dt = new DateTime(1970, 1, 1); List <School> all = new List <School>(); all.Add(new School("Isel", "chelas")); all.Add(new School("google", "ask your dns provider :P ")); Fixture <Student> fix = AutoFixture .For <Student>() .Member("BirthDate", () => dt.AddMonths(1)) .Member("AllSchools", () => { return(all); }); Student s = fix.New(); Assert.AreEqual(s.AllSchools, all); }
public void FillTest() { School school = new School(); school.Location = "Chelas"; school.Name = "ISEL"; Fixture <Student> fix = AutoFixture .For <Student>() .Member("School", () => { School sc = new School(); sc.Location = "Chelas"; sc.Name = "ISEL"; return(sc); }); Student s = fix.New(); Assert.IsNotNull(s); Assert.AreEqual(s.School, school); }
public object New() { return(new Student(Randomize.GetRandomInteger(), Randomize.GetRandomString(), (School)AutoFixture.For(typeof(School)).New())); }