public void ShouldSaveAccommodationLead()
 {
     var id = Guid.NewGuid();
     const string name = "Something";
     const string email = "*****@*****.**";
     const bool approved = false;
     var accommodationLead = new AccommodationLead
         {
             AccommodationLeadId = id,
             Name = name,
             Email = email,
             Approved = approved
         };
     var repository = new SqlContactQueryRepository();
     repository.Save(accommodationLead);
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         using (var command = connection.CreateCommand())
         {
             command.CommandText = "select * from AccommodationLeads where AccommodationLeadId=@Id";
             command.Parameters.AddWithValue("@Id", id);
             using (var reader = command.ExecuteReader())
             {
                 reader.Read();
                 Assert.That(reader.GetString(reader.GetOrdinal("Name")), Is.EqualTo(name));
                 Assert.That(reader.GetString(reader.GetOrdinal("Email")), Is.EqualTo(email));
                 Assert.That(reader.GetBoolean(reader.GetOrdinal("Approved")), Is.EqualTo(approved));
             }
         }
     }
 }
Пример #2
0
        public void ShouldSaveAccommodationLead()
        {
            var          id                = Guid.NewGuid();
            const string name              = "Something";
            const string email             = "*****@*****.**";
            const bool   approved          = false;
            var          accommodationLead = new AccommodationLead
            {
                AccommodationLeadId = id,
                Name     = name,
                Email    = email,
                Approved = approved
            };
            var repository = new SqlContactQueryRepository();

            repository.Save(accommodationLead);
            using (var connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "select * from AccommodationLeads where AccommodationLeadId=@Id";
                    command.Parameters.AddWithValue("@Id", id);
                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        Assert.That(reader.GetString(reader.GetOrdinal("Name")), Is.EqualTo(name));
                        Assert.That(reader.GetString(reader.GetOrdinal("Email")), Is.EqualTo(email));
                        Assert.That(reader.GetBoolean(reader.GetOrdinal("Approved")), Is.EqualTo(approved));
                    }
                }
            }
        }