Beispiel #1
0
 public Customer Save(Customer customer)
 {
     var command = BuildCustomerSaveCommand(customer);
     command.ExecuteNonQuery();
     customer.Id = command.GetParameterValue<int>("@Id");
     return customer;
 }
Beispiel #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;
        }
Beispiel #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");
        }
 public static Customer GetWellKnownCustomer()
 {
     Customer customer = new Customer
                             {
                                 FirstName = "Captain",
                                 LastName = "Hero",
                                 Title = "Super Hero",
                                 IsActive = true,
                                 CreatedBy = "Dave Jesser",
                                 ModifiedBy = "Xandir"
                             };
     return customer;
 }
        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;
        }
 public void Cyclops_MapsParameters_Success()
 {
     CustomerRepository customerRepository = GetCustomerRepository();
     Customer customer = new Customer {Id = 1, IsDeleted = false};
     customerRepository.Delete(customer);
 }
        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"));
        }
 public CyclopsCommand GetCustomerSaveCommand(Customer customer)
 {
     return BuildCustomerSaveCommand(customer);
 }
Beispiel #9
0
 public void Delete(Customer customer)
 {
     ConstructCommand("dbo.Customer_Delete").ExecuteNonQuery(customer.Id, customer.IsDeleted);
 }