Ejemplo n.º 1
0
        public override void Setup()
        {
            // Arrange
            base.Setup();
            dao = new ParkSqlDAO(ConnectionString);


            //Add a test park
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(
                    "INSERT INTO park (name, location, establish_date, area, visitors, description) VALUES ('Acadia', 'Ohio', '2010-01-01', '120', '120', 'Park'); SELECT SCOPE_IDENTITY()",
                    connection);

                connection.Open();

                newParkId = Convert.ToInt32(command.ExecuteScalar());
            }

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(
                    "INSERT INTO park (name, location, establish_date, area, visitors, description) VALUES ('Arches', 'Ohio', '2010-01-01', '120', '120', 'Park'); SELECT SCOPE_IDENTITY()",
                    connection);

                connection.Open();

                newParkId = Convert.ToInt32(command.ExecuteScalar());
            }

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(
                    "INSERT INTO park (name, location, establish_date, area, visitors, description) VALUES ('Cuyahoga Valley', 'Ohio', '2010-01-01', '120', '120', 'Park'); SELECT SCOPE_IDENTITY()",
                    connection);

                connection.Open();

                newParkId = Convert.ToInt32(command.ExecuteScalar());
            }
        }
        public void TestGetParks()
        {
            //Arrange
            ParkSqlDAO dao = new ParkSqlDAO(connectionString);

            //Act
            IList <Park> parks = dao.GetAllParks();
            int          i     = 0;

            for (; i < parks.Count; i++)
            {
                if (parks[i].ParkId == newParkId)
                {
                    break;
                }
            }

            //Assert
            Assert.AreEqual(2, parks.Count);
            Assert.AreEqual("Mount Rushmore", parks[i].Name);
        }
 public override void Setup()
 {
     base.Setup();
     dao = new ParkSqlDAO(ConnectionString);
 }