Ejemplo n.º 1
0
 public Customer Save(Customer customer)
 {
     var command = BuildCustomerSaveCommand(customer);
     command.ExecuteNonQuery();
     customer.Id = command.GetParameterValue<int>("@Id");
     return customer;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Useful for testing
        /// </summary>
        protected CyclopsCommand BuildCustomerSaveCommand(Customer customer)
        {
            var command = ConstructCommand<Customer>("dbo.Customer_Save")
                                        .MapAllParameters()
                                        .Build(customer);

            customer.Id = command.GetParameterValue<int>("@Id");

            return command;
        }
Ejemplo n.º 3
0
        public void ExtractOutputParameter()
        {
            var customer = new Customer{FirstName = "Sterling", LastName="Archer", CreatedBy="Pam"};

            var command = ConstructCommand<Customer>("dbo.Customer_Save")
                                        .MapAllParameters()
                                        .Build(customer);

            command.ExecuteNonQuery();

            customer.Id = command.GetParameterValue<int>("@Id");
        }
Ejemplo n.º 4
0
 public static Customer GetWellKnownCustomer()
 {
     Customer customer = new Customer
                             {
                                 FirstName = "Captain",
                                 LastName = "Hero",
                                 Title = "Super Hero",
                                 IsActive = true,
                                 CreatedBy = "Dave Jesser",
                                 ModifiedBy = "Xandir"
                             };
     return customer;
 }
Ejemplo n.º 5
0
        public static Customer GetUnpersistedCustomer()
        {
            var customer = new Customer();

            customer.FirstName = "Captain";
            customer.LastName = "Hero";
            customer.IsActive = true;
            customer.IsDeleted = false;
            customer.DateCreated = DateTime.Parse("2010-01-02 3:45");
            customer.DateModified = customer.DateCreated.AddHours(1);
            customer.CreatedBy = "unit test";
            customer.ModifiedBy = "unit test";
            return customer;
        }
Ejemplo n.º 6
0
 public void Cyclops_MapsParameters_Success()
 {
     CustomerRepository customerRepository = GetCustomerRepository();
     Customer customer = new Customer {Id = 1, IsDeleted = false};
     customerRepository.Delete(customer);
 }
Ejemplo n.º 7
0
        public void Cyclops_LogsFailure()
        {
            MemoryTarget target = GetMemoryTarget();
            try
            {
                CustomerRepository customerRepository = GetCustomerRepository();
                Customer customer = new Customer { Id = 1, IsDeleted = true };
                customerRepository.Delete(customer);
            }
            catch (Exception)
            {

            }

            List<string> logs = target.Logs.ToList();
            Assert.IsTrue(logs[0].Contains("You cannot delete an already deleted customer"));
        }
Ejemplo n.º 8
0
 public CyclopsCommand GetCustomerSaveCommand(Customer customer)
 {
     return BuildCustomerSaveCommand(customer);
 }
Ejemplo n.º 9
0
 public void Delete(Customer customer)
 {
     ConstructCommand("dbo.Customer_Delete").ExecuteNonQuery(customer.Id, customer.IsDeleted);
 }