public void CreateInstance_returns_the_object_returned_from_the_func()
 {
     var table = new Table("Field", "Value");
     var expectedPerson = new Person();
     var person = table.CreateInstance(() => expectedPerson);
     person.Should().Be(expectedPerson);
 }
 public FillInstanceHelperMethodTests()
     : base(t =>
                {
                    var person = new Person();
                    t.FillInstance(person);
                    return person;
                })
 {
 }
        public void Uses_the_instance_creation_method_when_passed_one_row()
        {
            var table = new Table("FirstName");
            table.AddRow("John");

            var expectedPerson = new Person();
            
            var people = table.CreateSet(() => expectedPerson);

            ObjectAssertExtensions.ShouldBeSameAs(people.Single(), expectedPerson);
        }
        public void Uses_the_instance_creation_method_when_passed_one_row()
        {
            var table = new Table("FirstName");
            table.AddRow("John");

            var expectedPerson = new Person();
            
            var people = table.CreateSet(() => expectedPerson);

            people.Single().Should().Be(expectedPerson);
        }
        public void Create_instance_will_fill_the_instance_()
        {
            var table = new Table("Field", "Value");
            table.AddRow("FirstName", "John");
            table.AddRow("LastName", "Galt");

            var expectedPerson = new Person { FirstName = "Ellsworth", LastName = "Toohey" };
            var person = table.CreateInstance(() => expectedPerson);

            person.FirstName.Should().Be("John");
            person.LastName.Should().Be("Galt");
        }
        public void Still_loads_the_instance_with_the_values_from_the_table()
        {
            var table = new Table("FirstName");
            table.AddRow("John");
            table.AddRow("Howard");

            var john = new Person();
            var howard = new Person();

            var queue = new Queue<Person>();
            queue.Enqueue(john);
            queue.Enqueue(howard);

            var people = table.CreateSet(queue.Dequeue);

            ObjectAssertExtensions.ShouldEqual(people.First().FirstName, "John");
            ObjectAssertExtensions.ShouldEqual(people.Last().FirstName, "Howard");
        }
        public void Still_loads_the_instance_with_the_values_from_the_table()
        {
            var table = new Table("FirstName");
            table.AddRow("John");
            table.AddRow("Howard");

            var john = new Person();
            var howard = new Person();

            var queue = new Queue<Person>();
            queue.Enqueue(john);
            queue.Enqueue(howard);

            var people = table.CreateSet(row => queue.Dequeue());

            people.First().FirstName.Should().Be("John");
            people.Last().FirstName.Should().Be("Howard");
        }
        public void Calls_the_instance_creation_method_for_each_row()
        {
            var table = new Table("FirstName");
            table.AddRow("one");
            table.AddRow("two");

            var first = new Person();
            var second = new Person();

            var queue = new Queue<Person>();
            queue.Enqueue(first);
            queue.Enqueue(second);

            var people = table.CreateSet(queue.Dequeue);

            ObjectAssertExtensions.ShouldEqual(people.Count(), 2);
            ObjectAssertExtensions.ShouldBeSameAs(people.First(), first);
            ObjectAssertExtensions.ShouldBeSameAs(people.Last(), second);
        }
        public void Calls_the_instance_creation_method_for_each_row()
        {
            var table = new Table("FirstName");
            table.AddRow("one");
            table.AddRow("two");

            var first = new Person();
            var second = new Person();

            var queue = new Queue<Person>();
            queue.Enqueue(first);
            queue.Enqueue(second);

            var people = table.CreateSet(row => queue.Dequeue());

            people.Count().Should().Be(2);
            people.First().Should().Be(first);
            people.Last().Should().Be(second);
        }
 private static void LastNameString_ShouldStartWith_FirstNameString(Person person)
 {
     person.LastName.Should().StartWith(person.FirstName);
 }