Пример #1
0
        private void removeBurritoBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    int     selectedIndex = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                    Burrito tBurrito      = newOrder.burritos[selectedIndex];

                    if (oManager.removeBurritoFromOrder(newOrder, tBurrito))
                    {
                        dataGridView1.Rows.RemoveAt(selectedIndex);

                        //update all burrito cell numbers
                        for (int n = 0; n < dataGridView1.Rows.Count; n++)
                        {
                            dataGridView1.Rows[n].Cells[0].Value = n;
                        }

                        //remove ingredients from Inventory
                        iManager.removeFromInventory(curInventory, tBurrito);
                        iManager.updateInventory(curInventory);

                        //update cost
                        updateTotalCost();
                    }
                }
            }
            catch (Exception err)
            {
                dLog.Error("Exception in removeBurritoBtn_Click: " + err.Message);
            }
        }
Пример #2
0
        private void editBurritoBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    bDialog.clearState(curInventory);

                    //keep track of the burrito we are modifying
                    int     selectedIndex = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                    Burrito tBurrito      = newOrder.burritos[selectedIndex];
                    bDialog.setBurrito(tBurrito);

                    if (bDialog.ShowDialog() == DialogResult.OK && oManager.updateBurritoInOrder(newOrder, bDialog.getNewBurrito()))
                    {
                        dataGridView1.Rows[selectedIndex].Cells[1].Value = bDialog.getBurritoType();
                        dataGridView1.Rows[selectedIndex].Cells[2].Value = bDialog.getNewBurrito().Price;

                        //remove ingredients from Inventory
                        iManager.removeFromInventory(curInventory, tBurrito);
                        iManager.removeFromInventory(curInventory, bDialog.getNewBurrito());
                        iManager.updateInventory(curInventory);

                        //update cost
                        updateTotalCost();
                    }
                }
            }
            catch (Exception err)
            {
                dLog.Error("Exception in editBurritoBtn_Click: " + err.Message);
            }
        }
Пример #3
0
        public void testBurritoSvc()
        {
            try {
                //week 3
                //IBurritoSvc ics = factory.getBurritoSvc();

                //week 4
                dLog.Debug("Going to get the service implementation");
                IBurritoSvc ics = (IBurritoSvc)factory.getService("IBurritoSvc");

                dLog.Debug("Going to create burrito");
                // First let's store the Burrito
                Assert.True(ics.storeBurrito(b));

                dLog.Debug("Going to read burrito");
                // Then let's read it back in
                b = ics.getBurrito(b.id);
                Assert.True(b.validate());

                // Update burrito
                dLog.Debug("Going to update burrito");
                b.Beef   = false;
                b.Hummus = true;
                Assert.True(ics.storeBurrito(b));

                dLog.Debug("Going to delete burrito");
                // Finally, let's cleanup the file that was created
                Assert.True(ics.deleteBurrito(b.id));
            }
            catch (Exception e) {
                Console.WriteLine("Exception in testBurritoSvc: " + e.Message + "\n" + e.StackTrace);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public String getBurritoType(Burrito b)
        {
            String result = "Unknown";

            try
            {
                if (b.Beef)
                {
                    result = "Beef";
                }
                else if (b.Chicken)
                {
                    result = "Chicken";
                }
                else if (b.Hummus)
                {
                    result = "Hummus";
                }
            }
            catch (Exception e)
            {
                dLog.Debug("Exception in getBurritoType: " + e.Message + "\n" + e.StackTrace);
                result = "Unknown";
            }

            return(result);
        }
        protected void SetUp()
        {
            XmlConfigurator.Configure(new FileInfo("config/log4net.properties"));
            dLog.Info("Beginning InventoryManagerTestCase Setup");
            rand = new Random();

            try {
                //iManager = new InventoryManager();
                //oManager = new OrderManager();

                //Spring.NET
                XmlApplicationContext ctx = new XmlApplicationContext("config/spring.cfg.xml");
                iManager = (InventoryManager)ctx.GetObject("InventoryManager");
                oManager = (OrderManager)ctx.GetObject("OrderManager");

                i = new Inventory(rand.Next(), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250));
                o = new Order(rand.Next(), new List <Burrito>(), new DateTime(), false, false, new Decimal(0));
                b = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));
            }
            catch (Exception e)
            {
                dLog.Error("Unable to initialize service/domain objects: " + e.Message + "\n" + e.StackTrace);
            }
            dLog.Info("Finishing InventoryManagerTestCase Setup");
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public Boolean removeBurritoFromOrder(Order o, Burrito b)
        {
            dLog.Debug("In removeBurritoFromOrder");
            Boolean result = false;

            try
            {
                if (b.validate())
                {
                    o.burritos.Remove(b);

                    if (orderSvc.storeOrder(o))
                    {
                        result = true;
                    }
                }
            }
            catch (Exception e)
            {
                dLog.Debug("Exception in updateBurritoInOrder: " + e.Message + "\n" + e.StackTrace);
                result = false;
            }

            dLog.Debug("removeBurritoFromOrder result: " + result);
            return(result);
        }
Пример #7
0
        /// <summary>
        /// This method retrieves a burrito.
        /// </summary>
        /// <param name="id">Unique ID of burrito to retrieve</param>
        /// <returns>burrito object</returns>
        public Burrito getBurrito(Int32 id)
        {
            dLog.Info("Entering method getBurrito | ID: " + id);
            Burrito  b       = new Burrito();
            ISession session = null;

            try {
                using (session = getSession()) {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        IQuery query = session.CreateQuery(@"FROM Burrito WHERE id = :id");
                        query.SetParameter("id", id);

                        b = query.List <Burrito>()[0];
                    }
                }
            }
            catch (Exception e2)
            {
                dLog.Error("Exception in getBurrito: " + e2.Message + "\n" + e2.StackTrace);
                b = new Burrito();
            }
            finally
            {
                //ensure that session is close regardless of the errors in try/catch
                if (session != null && session.IsOpen)
                {
                    session.Close();
                }
            }

            return(b);
        }
Пример #8
0
        /// <summary>
        /// This method retrieves a burrito.
        /// </summary>
        /// <param name="id">Unique ID of burrito to retrieve</param>
        /// <returns>burrito object</returns>
        public Burrito getBurrito(Int32 id)
        {
            dLog.Info("Entering method getBurrito | ID: " + id);
            Burrito b     = null;
            Stream  input = null;

            try {
                //ensure we were passed a valid object before attempting to write
                if (File.Exists("Burrito_" + id + ".txt"))
                {
                    input = File.Open("Burrito_" + id + ".txt", FileMode.Open);
                    BinaryFormatter bFormatter = new BinaryFormatter();
                    b = (Burrito)bFormatter.Deserialize(input);
                }
            }
            catch (IOException e1) {
                dLog.Error("IOException in getBurrito: " + e1.Message);
            }
            catch (TypeLoadException e2) {
                dLog.Error("TypeLoadException in getBurrito: " + e2.Message);
            }
            catch (Exception e3) {
                dLog.Error("Exception in getBurrito: " + e3.Message);
            }
            finally {
                //ensure that input is close regardless of the errors in try/catch
                if (input != null)
                {
                    input.Close();
                }
            }

            return(b);
        }
        public void testAddBurritoToOrder()
        {
            try
            {
                dLog.Info("Start testAddBurritoToOrder");
                o       = new Order(rand.Next(), new List <Burrito>(), new DateTime(), false, false, new Decimal(0));
                b       = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));
                b.Price = bManager.calculatePrice(b);
                oManager.addBurritoToOrder(o, b);
                o.totalCost = oManager.calculateTotal(o);

                Assert.True(oManager.createOrder(o));

                Assert.True(oManager.addBurritoToOrder(o, b));

                Assert.True(oManager.deleteOrder(o));

                dLog.Info("Finish testAddBurritoToOrder");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testAddBurritoToOrder: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #10
0
        public void testCalculatePrice()
        {
            try
            {
                dLog.Info("Start testCalculatePrice");
                b = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));

                Assert.True(bManager.createBurrito(b));

                b.Price = bManager.calculatePrice(b);
                if (b.Price == -1)
                {
                    Assert.Fail("Invalid price calculated for Burrito");
                }

                Assert.True(bManager.deleteBurrito(b));

                dLog.Info("Finish testCalculatePrice");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testCalculatePrice: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #11
0
        public void testUpdateBurrito()
        {
            try
            {
                dLog.Info("Start testUpdateBurrito");
                b = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));

                Assert.True(bManager.createBurrito(b));

                b.Beef          = nextBool();
                b.ChiliTortilla = nextBool();
                b.BlackBeans    = nextBool();
                b.Guacamole     = nextBool();
                b.PintoBeans    = nextBool();
                b.SalsaSpecial  = nextBool();

                Assert.True(bManager.updateBurrito(b));

                Assert.True(bManager.deleteBurrito(b));

                dLog.Info("Finish testUpdateBurrito");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testUpdateBurrito: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
        public void testInvalidSubmitOrder()
        {
            try
            {
                dLog.Info("Start testInvalidSubmitOrder");
                o       = new Order(rand.Next(), new List <Burrito>(), new DateTime(), false, false, new Decimal(0));
                b       = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));
                b.Price = bManager.calculatePrice(b);
                oManager.addBurritoToOrder(o, b);

                Assert.True(oManager.createOrder(o));

                dLog.Debug("Order ID: " + o.id);

                Assert.True(oManager.addBurritoToOrder(o, b));

                Assert.False(oManager.submitOrder(o));

                Assert.True(oManager.cancelOrder(o));

                dLog.Info("Finish testInvalidSubmitOrder");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testInvalidSubmitOrder: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public Boolean createBurrito(Burrito b)
        {
            dLog.Debug("In createBurrito");
            Boolean result = false;

            try
            {
                dLog.Debug("Validating burrito object");
                if (b.validate())
                {
                    if (burritoSvc.storeBurrito(b))
                    {
                        result = true;
                    }
                }
            }
            catch (Exception e)
            {
                dLog.Debug("Exception in createBurrito: " + e.Message + "\n" + e.StackTrace);
                result = false;
            }

            dLog.Debug("createBurrito result: " + result);
            return(result);
        }
Пример #14
0
 protected void SetUp()
 {
     factory = Factory.getInstance();
     o       = new Order(1, new List <Burrito>(), DateTime.Now, false, false, Decimal.Parse("17.00"));
     b       = new Burrito(1, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, Decimal.Parse("3.00"));
     o.burritos.Add(b);
 }
Пример #15
0
        public Burrito GetById(int id)
        {
            Burrito foundBurrito = _repo.GetById(id);

            if (foundBurrito == null)
            {
                throw new Exception("There is no burrito with that id");
            }
            return(foundBurrito);
        }
 public ActionResult <Burrito> CreateBurrito([FromBody] Burrito burrito)
 {
     try
     {
         return(Ok(_bs.Create(burrito)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #17
0
        public Burrito Create(Burrito burrito)
        {
            string sql = @"INSERT INTO burritos
      (title, description)
      VALUES
      (@Title, @Description);
      SELECT LAST_INSERT_ID();";

            burrito.Id = _db.ExecuteScalar <int>(sql, burrito);
            return(burrito);
        }
Пример #18
0
        private static void TestDecorator()
        {
            IBurrito burrito = new Burrito();

            burrito = new LettuceDecorator(burrito);
            burrito = new CilantroDecorator(burrito);
            burrito = new CheeseDecorator(burrito);

            burrito.Description();
            Console.ReadLine();
        }
Пример #19
0
        public void testEqualsObject()
        {
            try {
                Burrito b = new Burrito(1, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, Decimal.Parse("0.00"));
                Burrito c = b;

                Assert.True(b.Equals(c));
            }
            catch (Exception e) {
                Console.WriteLine("Exception in testEqualsObject: " + e.Message + "\n" + e.StackTrace);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #20
0
        public void testInvalidBurrito()
        {
            try {
                Burrito b = new Burrito();
                b.id = -1;

                Assert.False(b.validate());
            }
            catch (Exception e) {
                Console.WriteLine("Exception in testInvalidBurrito: " + e.Message + "\n" + e.StackTrace);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
        public override Dish CreateDish(DishType Type, DishOption Option)
        {
            Dish resultDish = null;

            if (Type == DishType.Burrito)
            {
                resultDish         = new Burrito();
                resultDish.Topping = new DefaultTopping("Burrito");
                resultDish.Country = Locale.US;
                resultDish.Price   = 45.00;
                if (Option == DishOption.Chicken)
                {
                    resultDish.Option = DishOption.Chicken;
                }
                else if (Option == DishOption.Meat)
                {
                    resultDish.Option = DishOption.Meat;
                }
                else
                {
                    resultDish.Option = DishOption.Vegitarian;
                }

                return(resultDish);
            }
            else
            {
                resultDish         = new Taco();
                resultDish.Topping = new DefaultTopping("Taco");
                resultDish.Country = Locale.US;
                resultDish.Price   = 40.00;
                if (Option == DishOption.Chicken)
                {
                    resultDish.Option = DishOption.Chicken;
                }
                else if (Option == DishOption.Meat)
                {
                    resultDish.Option = DishOption.Meat;
                }
                else
                {
                    resultDish.Option = DishOption.Vegitarian;
                }

                return(resultDish);
            }
        }
Пример #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="b"></param>
        public void setBurrito(Burrito b)
        {
            try
            {
                newBurrito = b;

                //set burrito Items
                beefChk.Checked    = newBurrito.Beef;
                ChickenChk.Checked = newBurrito.Chicken;
                hummusChk.Checked  = newBurrito.Hummus;

                chiliChk.Checked           = newBurrito.ChiliTortilla;
                herbGarlicChk.Checked      = newBurrito.HerbGarlicTortilla;
                jalapenoCheddarChk.Checked = newBurrito.JalapenoCheddarTortilla;
                tomatoBasilChk.Checked     = newBurrito.TomatoBasilTortilla;
                wheatChk.Checked           = newBurrito.WheatTortilla;
                flourTorillaChk.Checked    = newBurrito.FlourTortilla;

                whiteRiceChk.Checked = newBurrito.WhiteRice;
                brownRiceChk.Checked = newBurrito.BrownRice;

                blackBeansChk.Checked = newBurrito.BlackBeans;
                pintoBeansChk.Checked = newBurrito.PintoBeans;

                picoSalsaChk.Checked    = newBurrito.SalsaPico;
                salsaSpecialChk.Checked = newBurrito.SalsaSpecial;
                salsaVerdeChk.Checked   = newBurrito.SalsaVerde;

                guacamoleChk.Checked = newBurrito.Guacamole;

                cucumbersChk.Checked = newBurrito.Cucumber;
                jalapenosChk.Checked = newBurrito.Jalapenos;
                lettuceChk.Checked   = newBurrito.Lettuce;
                onionsChk.Checked    = newBurrito.Onion;
                tomatoesChk.Checked  = newBurrito.Tomatoes;

                updateBurritoCost();
            }
            catch (Exception e)
            {
                dLog.Error("Exception in updateBurritoCost: " + e.Message);
            }
        }
Пример #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_i"></param>
        public void clearState(Inventory _i)
        {
            try
            {
                curInventory      = _i;
                this.DialogResult = DialogResult.Cancel;
                newBurrito        = new Burrito();

                //reset UI
                beefChk.Checked            = false;
                ChickenChk.Checked         = false;
                hummusChk.Checked          = false;
                flourTorillaChk.Checked    = false;
                herbGarlicChk.Checked      = false;
                wheatChk.Checked           = false;
                chiliChk.Checked           = false;
                jalapenoCheddarChk.Checked = false;
                tomatoBasilChk.Checked     = false;
                whiteRiceChk.Checked       = false;
                brownRiceChk.Checked       = false;
                blackBeansChk.Checked      = false;
                pintoBeansChk.Checked      = false;
                picoSalsaChk.Checked       = false;
                salsaSpecialChk.Checked    = false;
                salsaVerdeChk.Checked      = false;
                guacamoleChk.Checked       = false;
                lettuceChk.Checked         = false;
                cucumbersChk.Checked       = false;
                jalapenosChk.Checked       = false;
                onionsChk.Checked          = false;
                tomatoesChk.Checked        = false;

                priceLbl.Text = "Total Price: $0.00";

                //initialize options based on inventory
                initAvailableOptions();
            }
            catch (Exception e)
            {
                dLog.Error("Exception in updateBurritoCost: " + e.Message);
            }
        }
Пример #24
0
        /// <summary>
        ///
        /// </summary>
        public BurritoDialog(Inventory _i)
        {
            try
            {
                //Spring.NET
                XmlApplicationContext ctx = new XmlApplicationContext("config/spring.cfg.xml");
                bManager = (BurritoManager)ctx.GetObject("BurritoManager");

                rand         = new Random();
                newBurrito   = new Burrito();
                curInventory = _i;

                initAvailableOptions();
            }
            catch (Exception e)
            {
                dLog.Debug("Exception | Unable to initialize business layer components: " + e.Message + "\n" + e.StackTrace);
            }

            InitializeComponent();
        }
        public void testCalculateTotal()
        {
            try
            {
                dLog.Info("Start testCalculateTotal");
                o = new Order(rand.Next(), new List <Burrito>(), new DateTime(), false, false, new Decimal(0));
                oManager.addBurritoToOrder(o, b);
                o.totalCost = oManager.calculateTotal(o);

                Assert.True(oManager.createOrder(o));

                dLog.Debug("Order ID: " + o.id);

                //randomly create some burritos to add to order
                for (int n = 0; n < rand.Next(2, 7); n++)
                {
                    b       = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));
                    b.Price = bManager.calculatePrice(b);
                    Assert.True(oManager.addBurritoToOrder(o, b));
                }

                o.totalCost = oManager.calculateTotal(o);
                dLog.Debug("Total cost of order: " + o.totalCost + " | Number of burritos: " + o.burritos.Count);
                if (o.totalCost == -1)
                {
                    Assert.Fail("Invalid total calculated for order");
                }

                Assert.True(oManager.submitOrder(o));

                Assert.True(oManager.cancelOrder(o));

                dLog.Info("Finish testCalculateTotal");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testCalculateTotal: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #26
0
        /// <summary>
        /// This method deletes a burrito.
        /// </summary>
        /// <param name="id">Unique ID of the burrito to delete</param>
        /// <returns>Success/Failure</returns>
        public Boolean deleteBurrito(Int32 id)
        {
            dLog.Info("Entering method deleteBurrito | ID:" + id);
            Boolean  result  = false;
            ISession session = null;

            try
            {
                using (session = getSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        IQuery query = session.CreateQuery(@"FROM Burrito WHERE id = :id");
                        query.SetParameter("id", id);
                        Burrito b = query.List <Burrito>()[0];
                        session.Delete(b);
                        transaction.Commit();

                        if (transaction.WasCommitted)
                        {
                            result = true;
                        }
                    }
                }
            }
            catch (Exception e2)
            {
                dLog.Error("Exception in deleteBurrito: " + e2.Message);
            }
            finally
            {
                //ensure that session is close regardless of the errors in try/catch
                if (session != null && session.IsOpen)
                {
                    session.Close();
                }
            }

            return(result);
        }
        public void testReturnToInventoryBurrito()
        {
            try
            {
                dLog.Info("Start testReturnToInventoryBurrito");
                i = new Inventory(rand.Next(), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250), rand.Next(10, 250));
                b = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));

                Assert.True(iManager.createInventory(i));

                Assert.True(iManager.returnToInventory(i, b));

                Assert.True(iManager.deleteInventory(i));

                dLog.Info("Finish testReturnToInventoryBurrito");
            }
            catch (Exception e)
            {
                dLog.Error("Exception in testReturnToInventoryBurrito: " + e.Message);
                Assert.Fail(e.Message + "\n" + e.StackTrace);
            }
        }
Пример #28
0
        static void Main(string[] args)
        {
            var pitsa = new Pitsa("Pepperoni", 33.5, 2);


            Console.ReadKey();

            var burrito = new Burrito("Mexican Hell", 50, true);

            Serialization.Serialize(pitsa, "pitsa.json");



            try
            {
                Serialization.Serialize(burrito, "burrito.json");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Пример #29
0
        /// <summary>
        /// This method stores a burrito.
        /// </summary>
        /// <param name="b">The burrito object to store</param>
        /// <returns>Success/Failure</returns>
        public Boolean storeBurrito(Burrito b)
        {
            dLog.Info("Entering method storeBurrito | ID: " + b.id);
            Stream  output = null;
            Boolean result = false;

            try {
                //ensure we were passed a valid object before attempting to write
                if (b.validate())
                {
                    dLog.Debug("Burrito object is valid, writing to file");
                    output = File.Open("Burrito_" + b.id + ".txt", FileMode.Create);
                    BinaryFormatter bFormatter = new BinaryFormatter();
                    bFormatter.Serialize(output, b);
                    result = true;
                }
                else
                {
                    dLog.Debug("Burrito object is not valid");
                }
            }
            catch (IOException e1) {
                dLog.Error("IOException in storeBurrito: " + e1.Message);
                result = false;
            }
            catch (Exception e2) {
                dLog.Error("Exception in storeBurrito: " + e2.Message);
                result = false;
            }
            finally {
                //ensure that output is close regardless of the errors in try/catch
                if (output != null)
                {
                    output.Close();
                }
            }

            return(result);
        }
Пример #30
0
        protected void SetUp()
        {
            XmlConfigurator.Configure(new FileInfo("config/log4net.properties"));
            dLog.Info("Beginning BurritoManagerTestCase Setup");
            rand = new Random();

            try
            {
                //bManager = new BurritoManager();

                //Spring.NET
                XmlApplicationContext ctx = new XmlApplicationContext("config/spring.cfg.xml");
                bManager = (BurritoManager)ctx.GetObject("BurritoManager");

                b = new Burrito(rand.Next(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), nextBool(), new Decimal(rand.NextDouble()));
            }
            catch (Exception e)
            {
                dLog.Error("Unable to initialize service/domain objects: " + e.Message + "\n" + e.InnerException + "\n" + e.StackTrace);
            }
            dLog.Info("Finishing BurritoManagerTestCase Setup");
        }