Ejemplo n.º 1
0
        public void CanGetIncidentByIncidentId()
        {
            Incident newInc = new Incident
            {
                IncidentId     = 123,
                IncidentTypeId = 44,
                OrderId        = 3,
                CustomerId     = 22,
                EmployeeId     = 45,
                Resolution     = "Told to shop elsewhere"
            };

            try
            {
                newInc.save();
                IncidentFactory newIncidentFactory = new IncidentFactory();
                var             incident           = newIncidentFactory.get(123);

                Assert.Equal(incident.IncidentId, 123);
                Assert.Equal(incident.IncidentTypeId, 44);
                Assert.Equal(incident.OrderId, 3);
                Assert.Equal(incident.CustomerId, 22);
                Assert.Equal(incident.EmployeeId, 45);
                Assert.Equal(incident.Resolution, "Told to shop elsewhere");
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        public void CanParseDate(string date)
        {
            var      fact       = new IncidentFactory();
            DateTime?parsedDate = IncidentFactory.ParseDate(date);

            Assert.Equal <DateTime?>(new DateTime(2016, 05, 10), parsedDate);
        }
Ejemplo n.º 3
0
        public void CreateRequiredRecords()
        {
            var orgFactory = new OrganizationServiceFactory();
            var orgSrv     = orgFactory.GetNewOrganizationService();
            var context    = new XrmServiceContext(orgSrv);

            var accFac = new AccountFactory();

            context.AddObject(accFac.CurrentEntity);

            var conFac = new ContactFactory();

            context.AddRelatedObject(accFac.CurrentEntity, new Relationship("contact_customer_accounts"), conFac.CurrentEntity);

            context.SaveChanges();

            var incFac = new IncidentFactory();

            incFac.CurrentEntity.CustomerId = accFac.CurrentEntity.ToEntityReference();
            context.AddObject(incFac.CurrentEntity);
            context.Attach(accFac.CurrentEntity);

            var wpFac = new WorkPackageFactory();

            context.AddRelatedObject(accFac.CurrentEntity, new Relationship("a24_account_workpackage_customer_ref"), wpFac.CurrentEntity);
            wpFac.CurrentEntity.a24_customer_ref = accFac.CurrentEntity.ToEntityReference();

            context.SaveChanges();
        }
        /**
         * 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;
            }
        }
        public void CanGetAnIncidentByEmployeeId(int id)
        {
            var fact     = new IncidentFactory();
            var incident = fact.getByEmployeeId(id);

            Assert.IsType <List <Incident> >(incident);
            Assert.NotNull(incident[0].IncidentId);
            Assert.NotNull(incident[0].EmployeeId);
            Assert.NotNull(incident[0].OrderId);
        }
        public void CanQuerySingleIncident(int id)
        {
            var      fact     = new IncidentFactory();
            Incident incident = fact.get(id);

            Assert.IsType <Incident>(incident);
            Assert.NotNull(incident.IncidentId);
            Assert.NotNull(incident.EmployeeId);
            Assert.NotNull(incident.OrderId);
        }
        public void CanQueryAllIncidents()
        {
            var             fact = new IncidentFactory();
            List <Incident> list = fact.getAll();

            Assert.IsType <List <Incident> >(list);
            Assert.NotNull(list[0].IncidentId);
            Assert.NotNull(list[0].EmployeeId);
            Assert.NotNull(list[0].OrderId);
        }
Ejemplo n.º 8
0
            public IncidentFactoryTest()
            {
                Table = new Mock <ITableWrapper>();

                Provider = new Mock <IAggregationProvider <IncidentEntity, IncidentGroupEntity> >();

                PathProvider = new Mock <IAffectedComponentPathProvider <IncidentEntity> >();

                Factory = new IncidentFactory(
                    Table.Object,
                    Provider.Object,
                    PathProvider.Object,
                    Mock.Of <ILogger <IncidentFactory> >());
            }
Ejemplo n.º 9
0
        public void CanSaveNewIncidentToDB()
        {
            var incident = new Incident();

            incident.EmployeeId     = 1;
            incident.IncidentTypeId = 1;
            incident.OrderId        = 1;
            incident.save();

            var             fact = new IncidentFactory();
            List <Incident> list = fact.getAll();
            Incident        last = list.Last();

            Assert.Equal(incident.EmployeeId, last.EmployeeId);
            Assert.Equal(incident.IncidentTypeId, last.IncidentTypeId);
            Assert.Equal(incident.OrderId, last.OrderId);
        }
Ejemplo n.º 10
0
        public void CanUpdateIncidentInDB()
        {
            var      fact = new IncidentFactory();
            Incident last = fact.getAll().Last();

            last.Resolution   = "Test Resolution";
            last.DateResolved = DateTime.Today;
            last.update();

            Incident updated = fact.get(last.IncidentId);

            Assert.Equal(updated.Resolution, last.Resolution);
            Assert.Equal(updated.DateResolved, last.DateResolved);
            // Remove Last Incident from Database
            if (last.IncidentId == updated.IncidentId)
            {
                var conn = new BangazonConnection();
                conn.insert($"DELETE FROM Incident WHERE IncidentId = {updated.IncidentId}");
            }
        }
Ejemplo n.º 11
0
        /**
         * Purpose: Reads user input for new incident information
         * Return:
         *     void
         */
        public static void ReadInput()
        {
            Console.WriteLine("Enter the customers first and last name to start:");
            Console.WriteLine("***********************************************************************");

            CustomerFactory customerFactory = new CustomerFactory();
            List <Customer> customerList    = customerFactory.getAll();

            foreach (Customer customer in customerList)
            {
                Console.WriteLine($"{ customer.FirstName} {customer.LastName} ");
            }
            Console.WriteLine("***********************************************************************");

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

            string   customerName = Console.ReadLine();
            Customer customerId   = customerFactory.getCustomerByFullName(customerName);

            while (customerId == null)
            {
                customerId = customerFactory.getCustomerByFullName(customerName);
                if (customerId == null)
                {
                    Console.WriteLine("This is not a valid answer. Please try again!");
                    customerName = Console.ReadLine();
                }
            }

            int orderID = 0;

            Console.WriteLine(@"
                ====================================
                BANGAZON INC CUSTOMER SERVICE PORTAL
                ====================================");
            Console.WriteLine("Choose a customer order:");
            OrderFactory orderFactory = new OrderFactory();
            List <Order> orderList    = orderFactory.getAllOrdersFromCustomer(customerId.CustomerId);

            foreach (Order order in orderList)
            {
                Console.WriteLine($"Order {order.OrderId}: { order.Date}");
            }
            Console.WriteLine("X.Exit");

            while (orderID == 0)
            {
                string orderIDAnswer = Console.ReadLine();
                if (orderIDAnswer.ToLower() == "x")
                {
                    return;
                    // to main menu
                }
                try
                {
                    orderID = Convert.ToInt32(orderIDAnswer);
                }
                catch
                {
                    Console.WriteLine("Please enter an order number.");
                }
            }

            IncidentFactory     incidentFactory     = new IncidentFactory();
            IncidentTypeFactory incidentTypeFactory = new IncidentTypeFactory();
            List <IncidentType> incidentTypeList    = incidentTypeFactory.getAll();
            List <Incident>     incidents           = incidentFactory.getAll();
            Incident            incident            = new Incident();

            incident.DateCreated = DateTime.Now;
            while (incident.OrderId <= 0 || orderList.TrueForAll(o => incident.OrderId != orderID))
            {
                if (orderList.Find(o => o.OrderId == orderID) != null)
                {
                    break;
                }

                if (orderList.TrueForAll(o => incident.OrderId != orderID) || orderID == 0)
                {
                    Console.WriteLine("This is not a valid answer. Try again!");
                    try
                    {
                        orderID = Convert.ToInt32(Console.ReadLine());
                    }
                    catch
                    {
                        Console.WriteLine("Please enter a number");
                    }
                }
            }

            incident.OrderId = orderID;
            Console.WriteLine(@"
                ====================================
                BANGAZON INC CUSTOMER SERVICE PORTAL
                ====================================");
            Console.WriteLine("Choose incident type: ");
            foreach (IncidentType incidentType in incidentTypeList)
            {
                Console.WriteLine($"{incidentType.IncidentTypeId} {incidentType.Label}");
            }
            Console.WriteLine("X.Exit");
            int incidentTypeId = 0;

            while (incidentTypeId == 0)
            {
                string incidentTypeIdAnswer = Console.ReadLine();
                if (incidentTypeIdAnswer.ToLower() == "x")
                {
                    // to main menu
                    return;
                }
                try
                {
                    incidentTypeId = Convert.ToInt32(incidentTypeIdAnswer);
                }
                catch
                {
                    Console.WriteLine("This is not a valid answer. Try again!");
                }
            }

            while (incident.IncidentTypeId <= 0 || incidentTypeList.TrueForAll(o => incident.IncidentTypeId != incidentTypeId))
            {
                if (incidentTypeList.Find(it => it.IncidentTypeId == incidentTypeId) != null)
                {
                    break;
                }

                if (incidentTypeList.TrueForAll(o => incident.IncidentTypeId != incidentTypeId) || incidentTypeId == 0)
                {
                    Console.WriteLine("This is not a valid answer. Try again!");
                    try
                    {
                        incidentTypeId = Convert.ToInt32(Console.ReadLine());
                    }
                    catch
                    {
                        Console.WriteLine("Please enter a number");
                    }
                }
            }
            incident.IncidentTypeId = incidentTypeId;
            CustomerFactory.Instance.ActiveCustomer = customerId;
            IncidentFactory.Instance.ActiveIncident = incident;
            ShowSingleIncidentAction.ReadInput();
        }
        public void CanInstantiateIncidentFactory()
        {
            var fact = new IncidentFactory();

            Assert.NotNull(fact);
        }