Пример #1
0
        public void outgoingTransactionsTest()
        {
            ICustomerFactory cust     = new CustomerFactory(1, "Kudela", "Gabriel");
            IAccountFactory  account  = new AccountFactory(AccountTypes.Oszczednosciowe, 1, 1);
            CustomerAccounts Accounts = new CustomerAccounts(cust, account);

            Accounts.Accounts[0].deposit(50000m, 1);
            Accounts.Accounts[0].newOutgoingTransaction(500m, 1, 2);

            List <Transaction> transactions = Accounts.OutgoingTransactions();

            Assert.AreEqual(1, transactions.Count);
            Assert.AreEqual(500m, transactions[0].Amount);
            Assert.AreEqual((uint)1, transactions[0].ClientCard);
            Assert.AreEqual((uint)2, transactions[0].ForeignCard);

            Accounts.Accounts[0].newOutgoingTransaction(20001m, 1, 1);

            try
            {
                transactions = Accounts.OutgoingTransactions();
                Assert.Fail("no exception thrown");
            }
            catch (UnauthorizedAccessException e)
            {
                Assert.AreEqual("over 20000 transfer", e.Message);
            }
        }
        public void FindCustomerMaterializaResultIfExist()
        {
            //Arrange
            var countryRepository  = new StubICountryRepository();
            var customerRepository = new StubICustomerRepository();
            var country            = new Country("spain", "es-ES");

            country.GenerateNewIdentity();

            customerRepository.GetGuid =
                (guid) =>
            {
                return(CustomerFactory.CreateCustomer(
                           "Jhon",
                           "El rojo",
                           "+3434344",
                           "company",
                           country,
                           new Address("city", "zipCode", "address line1", "address line2")));
            };

            var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

            //Act
            var result = customerManagementService.FindCustomer(Guid.NewGuid());

            //Assert
            Assert.IsNotNull(result);
        }
Пример #3
0
        public void GetAll_Returns_10_Orders()
        {
            var databaseName = Guid.NewGuid().ToString();

            using (var context = DbContextFactory.CreateInstance(databaseName))
            {
                //Arrange
                var customerRepository = new CustomerRepository(context);
                var orderRepository    = new OrderRepository(context);
                for (int i = 0; i < 10; i++)
                {
                    var customer = CustomerFactory.CreateValidEntity();
                    customerRepository.Add(customer);
                    var orderToAdd = OrderFactory.CreateValidEntity(customer);
                    orderRepository.Add(orderToAdd);
                }
                context.SaveChanges();

                //Act
                var orders = orderRepository.GetAll();

                //Assert
                Assert.AreEqual(10, orders.Count());
            }
        }
        public void FindCustomersInPageMaterializeResults()
        {
            //Arrange
            var countryRepository  = new StubICountryRepository();
            var customerRepository = new StubICustomerRepository();
            var country            = new Country("spain", "es-ES");

            country.GenerateNewIdentity();

            customerRepository.GetEnabledInt32Int32 = (index, count) =>
            {
                var customers = new List <Customer>();
                customers.Add(
                    CustomerFactory.CreateCustomer(
                        "Jhon",
                        "El rojo",
                        "+343",
                        "company",
                        country,
                        new Address("city", "zipCode", "address line", "address line2")));
                return(customers);
            };

            var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

            //Act
            var result = customerManagementService.FindCustomers(0, 1);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
        }
        public void FindCustomersByFilterMaterializeResults()
        {
            //Arrange
            var countryRepository  = new StubICountryRepository();
            var customerRepository = new StubICustomerRepository();
            var country            = new Country("Spain", "es-ES");

            country.GenerateNewIdentity();

            customerRepository.AllMatchingISpecificationOfCustomer = (spec) =>
            {
                var customers = new List <Customer>();
                customers.Add(
                    CustomerFactory.CreateCustomer(
                        "Jhon",
                        "El rojo",
                        "+34343",
                        "company",
                        country,
                        new Address("city", "zipCode", "address line", "address line2")));
                return(customers);
            };

            var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

            //Act
            var result = customerManagementService.FindCustomers("Jhon");

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
        }
Пример #6
0
        public CustomerDTO AddNewCustomer(CustomerDTO customerDTO)
        {
            //check preconditions
            if (customerDTO == null || customerDTO.CountryId == Guid.Empty)
            {
                throw new ArgumentException(_resources.GetStringResource(LocalizationKeys.Application.warning_CannotAddCustomerWithEmptyInformation));
            }

            var country = _countryRepository.Get(customerDTO.CountryId);

            if (country != null)
            {
                //Create the entity and the required associated data
                var address = new Address(customerDTO.AddressCity, customerDTO.AddressZipCode, customerDTO.AddressAddressLine1, customerDTO.AddressAddressLine2);

                var customer = CustomerFactory.CreateCustomer(customerDTO.FirstName,
                                                              customerDTO.LastName,
                                                              customerDTO.Telephone,
                                                              customerDTO.Company,
                                                              country,
                                                              address);

                //save entity
                SaveCustomer(customer);

                //return the data with id and assigned default values
                return(customer.ProjectedAs <CustomerDTO>());
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        public void CustomerRepositoryRemoveItemDeleteIt()
        {
            //Arrange
            var customerRepository = new CustomerRepository(fixture.unitOfWork, fixture.customerLogger);

            var country = new Country("Spain", "es-ES");

            country.ChangeCurrentIdentity(new Guid("32BB805F-40A4-4C37-AA96-B7945C8C385C"));

            var address = new Address("city", "zipCode", "addressline1", "addressline2");

            var customer = CustomerFactory.CreateCustomer("Frank", "Frank", "+3444", "company", country, address);

            customer.SetTheCountryReference(country.Id);

            customerRepository.Add(customer);
            fixture.unitOfWork.Commit();

            //Act
            customerRepository.Remove(customer);
            fixture.unitOfWork.Commit();

            var result = customerRepository.Get(customer.Id);

            //Assert
            Assert.Null(result);
        }
Пример #8
0
        public void AdaptBankAccountToBankAccountDTO()
        {
            //Arrange
            var country = new Country("Spain", "es-ES");

            country.GenerateNewIdentity();

            var customer = CustomerFactory.CreateCustomer("jhon", "el rojo", "+3441", "company", country, new Address("", "", "", ""));

            customer.GenerateNewIdentity();

            BankAccount account = new BankAccount();

            account.GenerateNewIdentity();
            account.BankAccountNumber = new BankAccountNumber("4444", "5555", "3333333333", "02");
            account.SetCustomerOwnerOfThisBankAccount(customer);
            account.DepositMoney(1000, "reason");
            account.Lock();

            //Act
            ITypeAdapter adapter        = TypeAdapterFactory.CreateAdapter();
            var          bankAccountDTO = adapter.Adapt <BankAccount, BankAccountDTO>(account);


            //Assert
            Assert.AreEqual(account.Id, bankAccountDTO.Id);
            Assert.AreEqual(account.Iban, bankAccountDTO.BankAccountNumber);
            Assert.AreEqual(account.Balance, bankAccountDTO.Balance);
            Assert.AreEqual(account.Customer.FirstName, bankAccountDTO.CustomerFirstName);
            Assert.AreEqual(account.Customer.LastName, bankAccountDTO.CustomerLastName);
            Assert.AreEqual(account.Locked, bankAccountDTO.Locked);
        }
Пример #9
0
        public Customer GetCustomer(string phone)
        {
            Customer customer;

            string query = Utility.ReadSQLQueryFromFile("GetCustomer.txt");

            SQLQuery sQLQuery = new SQLQuery(query);

            sQLQuery.AddParameter("@phone", phone, SqlDbType.VarChar);

            SQLQueryResult sQLQueryResult = SQLDatabaseConnector.QueryDatabase(sQLQuery);

            if (sQLQueryResult.code == 0 && sQLQueryResult.dataTable.Rows.Count > 0)
            {
                DataRow dataRow = sQLQueryResult.dataTable.Rows[0];

                customer = CustomerFactory.Instance().CreateCustomer((int)dataRow["CustomerID"], (string)dataRow["Name"], (string)dataRow["Adress"], (string)dataRow["Phone"], (string)dataRow["Email"], (bool)dataRow["Active"], (int)dataRow["cvr"]);

                return(customer);
            }
            else
            {
                throw new NoCustomerFoundException("", sQLQueryResult.exception);
            }
        }
        public void OrderLine_IsValid_Returns_True_When_Valid()
        {
            //Arrange
            var customer = CustomerFactory.CreateValidEntity();

            customer.Id = Guid.NewGuid();
            var order = OrderFactory.CreateValidEntity(customer);

            order.Id = Guid.NewGuid();
            var product = ProductFactory.CreateValidEntity();

            product.Id = Guid.NewGuid();
            var article = ArticleFactory.CreateValidEntity(product);

            article.Id = Guid.NewGuid();
            var orderLine = OrderLineFactory.CreateValidEntity(order, article);

            orderLine.Id = Guid.NewGuid();

            //Act
            var result = orderLine.IsValid();

            //Assert
            Assert.IsTrue(result);
        }
Пример #11
0
        public void Remove_Deletes_Customer()
        {
            //Arrange
            var  databaseName = Guid.NewGuid().ToString();
            Guid customerId;

            using (var context = DbContextFactory.CreateInstance(databaseName))
            {
                var customer = CustomerFactory.CreateValidEntity();
                context.Customers.Add(customer);
                customerId = customer.Id;
                context.SaveChanges();
            }

            //Act
            using (var context = DbContextFactory.CreateInstance(databaseName))
            {
                var customerRepository = new CustomerRepository(context);
                customerRepository.Remove(customerId);
                context.SaveChanges();
            }

            //Assert
            using (var context = DbContextFactory.CreateInstance(databaseName))
            {
                var dbCustomer = context.Customers.Find(customerId);

                Assert.IsNull(dbCustomer);
            }
        }
Пример #12
0
        public void IsCreditValidForOrderReturnFalseIfTotalOrderIsGreaterThanCustomerCredit()
        {
            //Arrange
            var shippingName    = "shippingName";
            var shippingCity    = "shippingCity";
            var shippingZipCode = "shippingZipCode";
            var shippingAddress = "shippingAddress";

            var country = new Country("spain", "es-ES");

            country.GenerateNewIdentity();

            var customer = CustomerFactory.CreateCustomer(
                "jhon",
                "el rojo",
                "+3422",
                "company",
                country,
                new Address("city", "zipCode", "address line1", "addres line2"));

            //Act
            var order = OrderFactory.CreateOrder(customer, shippingName, shippingCity, shippingAddress, shippingZipCode);

            order.AddNewOrderLine(Guid.NewGuid(), 100, 240, 0);
            // this is greater that 1000 ( default customer credit )

            //assert
            var result = order.IsCreditValidForOrder();

            //Assert
            Assert.IsFalse(result);
        }
Пример #13
0
        public void GetCustomerBasedOnOrderLessOrEqualTo100()
        {
            var customer = CustomerFactory.CreateCustomerInstanceBasedOnOrderQty(80);

            //This shows a warning to not use it, this will return void and can not be extended, means, we can not look into the object built.
            //Assert.IsType(typeof(Customer), customer);
            Assert.IsType <Customer>(customer);
        }
Пример #14
0
        public void LocalCustomerForOrdersGreatherThan100()
        {
            var customer = CustomerFactory.CreateCustomer(102);

            var loyalCustomer = Assert.IsType <LoyalCustomer>(customer);

            Assert.Equal(10, loyalCustomer.Discount);
        }
Пример #15
0
 private static void InsertCustomers(int numOfItterations, int numOfCustomers, ISisoDatabase database)
 {
     for (var c = 0; c < numOfItterations; c++)
     {
         var customers = CustomerFactory.CreateCustomers(numOfCustomers);
         InsertCustomers(customers, database);
     }
 }
Пример #16
0
 public OverInjecting(IEventBus eventBus, ISystemClock systemClock, IReservationService reservationService, ICustomerRepository customerRepository, CustomerFactory customerFactory)
 {
     _eventBus           = eventBus;
     _systemClock        = systemClock;
     _reservationService = reservationService;
     _customerRepository = customerRepository;
     _customerFactory    = customerFactory;
 }
Пример #17
0
 public SBCustomerController()
 {
     _factory = new CustomerFactory();
     //================
     ViewBag.ListStore  = GetListStore();
     listPropertyReject = new List <string>();
     listPropertyReject.Add("Marital");
 }
Пример #18
0
        public void UpdateCustomerTestMethod()
        {
            Customer        customer        = CustomerFactory.Instance().CreateCustomer("hans", "Vejvej", "654", "*****@*****.**", true, 0);
            CustomerManager customerManager = new CustomerManager();
            string          updateCustomer  = customerManager.UpdateCustomer(customer);

            Assert.AreEqual("Kunde rettet", updateCustomer);
        }
Пример #19
0
        public void getCustomerTest()
        {
            domain.Customer customer = CustomerFactory.getCustomer("John", "Doe", "789 456 123");

            Assert.AreEqual("John", customer.Name);
            Assert.AreEqual("Doe", customer.Surname);
            Assert.AreEqual("789 456 123", customer.PhoneNumber);
        }
Пример #20
0
        public void addCustomer(string name, string surname)
        {
            ICustomerFactory customer = new CustomerFactory(this.CustId, name, surname);
            IAccountFactory  acc      = new AccountFactory(AccountTypes.Oszczednosciowe, this.CustId,
                                                           this.Signature * 1000 + this.ID);

            this._customerAccounts.Add(new CustomerAccounts(customer, acc));
        }
Пример #21
0
        public async Task EditAsync(CustomerEditModel model)
        {
            var customer = await _customerRepository.GetAsync(model.Id);

            CustomerFactory.Update(model, customer, _userId);
            _customerRepository.Edit(customer);
            await _unitOfWork.SaveChangesAsync();
        }
Пример #22
0
 public OrderViewModel()
 {
     this.quattroRepository  = new QuattroRepository();
     this.customerRepository = new CustomerRepository();
     this.productRepository  = new ProductRepository();
     this._salesHeaderView   = SalesFactory.createNewSalesHeader();
     this.selectedProduct    = ProductFactory.createProduct();
     selectedCustomer        = CustomerFactory.createNew();
 }
Пример #23
0
        public void CustomerFactoryWillGetSingleCustomerFromDatabase()
        {
            CustomerFactory factory  = new CustomerFactory();
            Customer        customer = factory.get(1);

            Assert.Equal("Carson", customer.FirstName);
            Assert.Equal("Alexander", customer.LastName);
            Assert.Equal(1, customer.CustomerId);
        }
        /**
         * Class: ListIncidentsAction
         * Purpose: Lists all incidents for the current employee
         * Author: Dayne Wright
         * Methods:
         *     static void ReadInput() - Shows the list of incidents and sets selected
         */
        public static void ReadInput()
        {
            Employee employee = EmployeeFactory.Instance.ActiveEmployee;

            CustomerFactory custFact     = new CustomerFactory();
            OrderFactory    orderFact    = new OrderFactory();
            IncidentFactory incidentFact = new IncidentFactory();

            Console.WriteLine(@"
====================================
BANGAZON INC CUSTOMER SERVICE PORTAL
====================================");
            Console.WriteLine();

            List <Incident> incidents = incidentFact.getByEmployeeId(employee.EmployeeId);


            incidents.ForEach(delegate(Incident i)
            {
                Order order       = orderFact.get(i.OrderId);
                Customer customer = custFact.get(order.CustomerId);

                Console.WriteLine($"{i.IncidentId}. {customer.LastName}, {customer.FirstName} : Order {order.OrderId}");
            });
            Console.WriteLine("X.Exit");
            Console.Write("> ");
            int selection = 0;

            while (selection == 0)
            {
                try
                {
                    string input = Console.ReadLine();

                    if (input.ToLower() == "x")
                    {
                        return; // to main menu
                    }

                    selection = Convert.ToInt32(input);

                    if (incidents.Find(i => i.IncidentId == selection).IncidentId == selection)
                    {
                        IncidentFactory.Instance.ActiveIncident = incidentFact.get(selection);
                        CustomerFactory.Instance.ActiveCustomer = custFact.get(orderFact.get(IncidentFactory.Instance.ActiveIncident.OrderId).CustomerId);
                        ShowSingleIncidentAction.ReadInput();
                        return;
                    }
                }
                catch
                {
                    Console.WriteLine("Sorry!  That is not a valid incident number.  Please select an incident from above.");
                    Console.Write("> ");
                }
                selection = 0;
            }
        }
Пример #25
0
        public CustomerEntity GetCustomer(int custNo)
        {
            AspnetAppCustomers Appcustomer = checkNetDbContext.AspnetAppCustomers.Find(custNo);

            CustomerEntity customerEntity = CustomerFactory.Create(custNo, Appcustomer.Address1, Appcustomer.Address2, Appcustomer.Name,
                                                                   Appcustomer.City, Appcustomer.State, Appcustomer.ZipCode, Appcustomer.PhoneNo, Appcustomer.StatusCode, Appcustomer.LastUpdatedBy, Appcustomer.LastUpdateDate);

            return(customerEntity);
        }
Пример #26
0
        public void CreateCustomerTestMethod()
        {
            Customer customer = CustomerFactory.Instance().CreateCustomer("hans", "Vejvej", random.Next(1000000, 10000000).ToString(), "*****@*****.**", true, 0);

            CustomerManager customerManager = new CustomerManager();

            customerManager.CreateCustomer(customer);
            Assert.AreNotEqual(0, customer.customerID);
        }
Пример #27
0
        public async Task <int> AddAsync(CustomerAddModel model)
        {
            var customer = CustomerFactory.Create(model, _userId);
            await _customerRepository.AddAsync(customer);

            await _unitOfWork.SaveChangesAsync();

            return(customer.Id);
        }
Пример #28
0
        private static void RepoDbBatchInsert(int count)
        {
            var customers  = CustomerFactory.CreateCustomers(count).AsList();
            var now        = DateTime.UtcNow;
            var repository = new RepoDbCustomerRepository();

            repository.BatchInsert(customers);
            Console.WriteLine($"{(DateTime.UtcNow - now).TotalSeconds} second(s) for RepoDb with {customers.Count} customers.");
        }
Пример #29
0
        public RoutingDataModel CreateInitialSimulationDataModel(bool allowDropNodes, Simulation.Simulation simulation)
        {
            var numberCustomers = simulation.Params.NumberInitialRequests;
            var numberVehicles  = simulation.Params.VehicleNumber;

            Console.WriteLine(this.ToString() + "Creating new random DataModel for " + numberVehicles + " Vehicles and " + numberCustomers + " Customers, AllowDropNodes: " + allowDropNodes);
GenerateNewDataModelLabel:
            List <Vehicle> dataModelVehicles   = new List <Vehicle>();
            List <long> startDepotsArrivalTime = new List <long>(numberVehicles);

            //Creates two available vehicles to be able to perform flexible routing for the pdtwdatamodel
            for (int i = 0; i < numberVehicles; i++)
            {
                var vehicle = new Vehicle(simulation.Params.VehicleSpeed, simulation.Params.VehicleCapacity, simulation.Context.Depot, simulation.Context.Depot);
                dataModelVehicles.Add(vehicle);
                startDepotsArrivalTime.Add(0);//startDepotArrival time  = 0 for all the vehicles
            }

            var         customersToBeServed = new List <Customer>();
            List <Stop> excludedStops       = new List <Stop>();

            foreach (var vehicle in dataModelVehicles)
            {
                if (!excludedStops.Contains(vehicle.StartStop))
                {
                    excludedStops.Add(vehicle.StartStop);
                }

                if (!excludedStops.Contains(vehicle.EndStop))
                {
                    excludedStops.Add(vehicle.EndStop);
                }
            }

            for (int i = 0; i < numberCustomers; i++) //generate 5 customers with random timeWindows and random pickup and delivery stops
            {
                var requestTime      = 0;
                var pickupTimeWindow = new int[] { requestTime, simulation.Params.SimulationTimeWindow[1] };                                                                                           //the customer pickup time will be between the current request time and the end of simulation time
                var customer         = CustomerFactory.Instance().CreateRandomCustomer(simulation.Context.Stops, excludedStops, requestTime, pickupTimeWindow, false, simulation.Params.VehicleSpeed); //Generates a random static customer
                customersToBeServed.Add(customer);
            }
            var indexManager = new DataModelIndexManager(dataModelVehicles, customersToBeServed, startDepotsArrivalTime);

            var routingDataModel = new RoutingDataModel(indexManager, simulation.Params.MaximumRelativeCustomerRideTime, simulation.Params.MaximumAllowedDeliveryDelay);
            var solver           = new RoutingSolver(routingDataModel, allowDropNodes);
            RoutingSearchParameters searchParameters = operations_research_constraint_solver.DefaultRoutingSearchParameters();

            searchParameters.LocalSearchMetaheuristic = LocalSearchMetaheuristic.Types.Value.Automatic;
            searchParameters.SolutionLimit            = 1; //until it finds 1 solution
            var solution = solver.TryGetSolution(searchParameters);

            if (solution == null)
            {
                goto GenerateNewDataModelLabel;
            }
            return(routingDataModel);
        }
Пример #30
0
        public void XmlFormatter_WhenCustomerHaveMultipleRentals_ShouldPass()
        {
            var      customer       = CustomerFactory.GetCustomer();
            var      xmlFormatter   = new XmlFormatter();
            var      serializedData = customer.GetStatement(xmlFormatter);
            Customer actual         = xmlFormatter.Deserialize(serializedData);

            Assert.True(customer.Equals(actual));
        }
        public CustomerRepository(CustomerFactory factory, string serviceUri)
        {
            this.serviceUri = serviceUri; //The service Uri you'll use to fetch the data from.

            customersData = new List<Customer>
                             	{
                             		factory.Invoke("John", "Doe", 30),
                             		factory.Invoke("Jane", "Doe", 25)
                             	};
        }
Пример #32
0
        public void Context()
        {
            var factory = new CustomerFactory();

            _customer = factory.Create();
        }