Exemple #1
0
        public void backStagePassesIncreaseBy3With5DaysOrLess()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = 6, Quality = 40, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = 5, Quality = 43
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #2
0
        public void backStagePassesDropToZeroAfterConcert()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = 1, Quality = 50, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = 0, Quality = 0
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #3
0
        public void agedBrieIncreasesInQualityWithAge()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new AgedBrie {
                Name = "Aged Brie", Sellin = 2, Quality = 2, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new AgedBrie {
                Name = "Aged Brie", Sellin = 1, Quality = 3
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #4
0
        public void sulfurasNeverDecreasesInQuality()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new LegendaryItem {
                Name = "Sulfuras", Sellin = 2, Quality = 50, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new LegendaryItem {
                Name = "Sulfuras", Sellin = 2, Quality = 50
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #5
0
        public void qualityOfStandardItemNeverMoreThan50WhenSetFirstTime()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new StandardItem {
                Name = "Normal Item", Sellin = 2, Quality = 51, Timer = timer
            });

            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new StandardItem {
                Name = "Normal Item", Sellin = 1, Quality = 50
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #6
0
        public void itemWithNegativeQualityIsSetToZero()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new StandardItem {
                Name = "Normal Item", Sellin = 1, Quality = -1, Timer = timer
            });

            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new StandardItem {
                Name = "Normal Item", Sellin = 0, Quality = 0
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #7
0
        public void standardItemSellinAndQualityDecreaseOnDayPassedAndSellByPassed()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new StandardItem {
                Name = "Normal Item", Sellin = 1, Quality = 2, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new StandardItem {
                Name = "Normal Item", Sellin = 0, Quality = 0
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #8
0
        public void conjuredItemsdegradeInQualityTwiceAsFastAsNormalItems()
        {
            // Arrange
            var timer = new MeasureTime();

            var currentStock = new List <IStockable>();

            currentStock.Add(new ConjuredItem {
                Name = "Conjured", Sellin = 5, Quality = 50, Timer = timer
            });


            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new ConjuredItem {
                Name = "Conjured", Sellin = 4, Quality = 48
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);

            // Act
            timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string articleREF = reference.Text;

            DB.RemoveArticleByRef(articleREF, con);
            ManageStock.RemoveArticleByRef(stock_article, int.Parse(articleREF));
            Refresh();
        }
Exemple #10
0
        public void RetrieveUpdatedStockAfter1Day()
        {
            // Arrange
            var currentStock = new List <IStockable>();

            currentStock.Add(ItemFactory.getStock("Aged Brie", 1, 1));
            currentStock.Add(ItemFactory.getStock("Backstage Passes", -1, 2));
            currentStock.Add(ItemFactory.getStock("Backstage Passes", 9, 2));
            currentStock.Add(ItemFactory.getStock("Sulfuras", 2, 2));
            currentStock.Add(ItemFactory.getStock("Normal Item", -1, 55));
            currentStock.Add(ItemFactory.getStock("Normal Item", 2, 2));
            currentStock.Add(ItemFactory.getStock("INVALID ITEM", 2, 2));
            currentStock.Add(ItemFactory.getStock("Conjured", 2, 2));
            currentStock.Add(ItemFactory.getStock("Conjured", -1, 5));

            var expectedStockAfter1Day = new List <IStockable>();

            expectedStockAfter1Day.Add(new AgedBrie {
                Name = "Aged Brie", Sellin = 0, Quality = 2
            });
            expectedStockAfter1Day.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = -2, Quality = 0
            });
            expectedStockAfter1Day.Add(new BackStagePass {
                Name = "Backstage Passes", Sellin = 8, Quality = 4
            });
            expectedStockAfter1Day.Add(new LegendaryItem {
                Name = "Sulfuras", Sellin = 2, Quality = 2
            });
            expectedStockAfter1Day.Add(new StandardItem {
                Name = "Normal Item", Sellin = -2, Quality = 50
            });
            expectedStockAfter1Day.Add(new StandardItem {
                Name = "Normal Item", Sellin = 1, Quality = 1
            });
            expectedStockAfter1Day.Add(new NoSuchItem {
                Name = "NO SUCH ITEM"
            });
            expectedStockAfter1Day.Add(new ConjuredItem {
                Name = "Conjured", Sellin = 1, Quality = 0
            });
            expectedStockAfter1Day.Add(new ConjuredItem {
                Name = "Conjured", Sellin = -2, Quality = 1
            });

            var stockManager = new ManageStock();

            stockManager.AddStock(currentStock);



            // Act
            ItemFactory.timer.advanceDay();
            var finalStock = stockManager.GetStock();

            // Assert
            CollectionAssert.AreEqual(finalStock, expectedStockAfter1Day, new StockComparer());
        }
Exemple #11
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            string  articleREF      = reference.Text;
            string  articleNAME     = name.Text;
            string  articlePRICE    = price.Text;
            string  articleQUANTITY = stock.Text;
            article newArticle      = new article(Int32.Parse(articleREF), articleNAME, Convert.ToDouble(articlePRICE), Int32.Parse(articleQUANTITY));

            ManageStock.ModifyArticle(stock_article, Int32.Parse(articleREF), newArticle);
            DB.ModifyArticle(newArticle, con);
            Refresh();
        }
Exemple #12
0
 private void ManagerForm_Load(object sender, EventArgs e)
 {
     try
     {
         ConnectioString = ConfigurationManager.ConnectionStrings["cns"].ConnectionString;
         mngStock        = new ManageStock(ConnectioString);
         List <StockModels> lstStock = mngStock.GetAllStock();
         gridStock.DataSource = lstStock;
         gridStock.ClearSelection();
         bindCombobox();
     }
     catch (Exception ex)
     {
         Logger.WriteErrorMessage(ex);
     }
 }
Exemple #13
0
        private void AddStockForm_Load(object sender, EventArgs e)
        {
            try
            {
                mngStock = new ManageStock(ConnectionString);

                cmbxProductName.DataSource    = this.Products;
                cmbxProductName.DisplayMember = "ProductName";

                cmbCompany.DataSource    = this.Companies;
                cmbCompany.DisplayMember = "CompanyName";
            }
            catch (Exception ex)
            {
                Logger.WriteErrorMessage(ex);
            }
        }
        public void CheckIfFileExists(FileName fileName)
        {
            string path = $@"Dal\{fileName}.json";

            if (fileName == FileName.CarComponents)
            {
                if (!File.Exists(path))
                {
                    ManageStock manageStock = new ManageStock();
                    Dictionary <string, int> CarComponents = manageStock.CarComponentsDefault();

                    _ = SaveData(CarComponents, FileName.CarComponents);
                }
            }
            if (fileName == FileName.BusComponents)
            {
                if (!File.Exists(path))
                {
                    ManageStock manageStock = new ManageStock();
                    Dictionary <string, int> BusComponents = manageStock.BusComponentsDefault();

                    _ = SaveData(BusComponents, FileName.BusComponents);
                }
            }
            if (fileName == FileName.TruckComponents)
            {
                if (!File.Exists(path))
                {
                    ManageStock manageStock = new ManageStock();
                    Dictionary <string, int> TruckComponents = manageStock.TruckComponentsDefault();

                    _ = SaveData(TruckComponents, FileName.TruckComponents);
                }
            }
            if (fileName == FileName.MotorbikeComponents)
            {
                if (!File.Exists(path))
                {
                    ManageStock manageStock = new ManageStock();
                    Dictionary <string, int> MotorbikeComponents = manageStock.MotorbikeComponentsDefault();

                    _ = SaveData(MotorbikeComponents, FileName.MotorbikeComponents);
                }
            }
        }
Exemple #15
0
        public void GetProductAndCompany()
        {
            try
            {
                mngStock = new ManageStock(ConnectionString);
                List <Product> lstProduct = mngStock.GetProduct();
                gridProduct.DataSource = lstProduct;
                gridProduct.ClearSelection();

                List <Company> lstCmp = mngStock.GetCompany();
                gridComp.DataSource = lstCmp;
                gridComp.ClearSelection();
            }
            catch (Exception ex)
            {
                Logger.WriteErrorMessage(ex);
            }
        }
        private void UpdateStockForm_Load(object sender, EventArgs e)
        {
            mngStock = new ManageStock(Connection);
            cmbProductName.DataSource    = this.Products;
            cmbProductName.DisplayMember = "ProductName";
            cmbCompany.DataSource        = this.Companies;
            cmbCompany.DisplayMember     = "CompanyName";

            cmbProductName.Text = Stock.ProductName;
            cmbCompany.Text     = Stock.Company;
            txtWeight.Text      = !string.IsNullOrEmpty(Stock.Weight) ? Stock.Weight.Substring(0, (Stock.Weight.Length - 2)) : "";
            cmbUnit.Text        = !string.IsNullOrEmpty(Stock.Weight) ? Stock.Weight.Substring(Stock.Weight.Length - 2) : "";
            txtStock.Text       = Stock.Stock;
            txtCgst.Text        = Stock.CGST;
            txtIgst.Text        = Stock.IGST;
            txtMrp.Text         = Stock.MRP;
            txtRate.Text        = Stock.Rate;
            txtSgst.Text        = Stock.SGST;
            txtDetails.Text     = Stock.Details;
        }
        public string Get(string Code, string Type)
        {
            ManageSQLConnection manageSQLConnection = new ManageSQLConnection();
            DataSet             ds = new DataSet();
            List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >();
            ManageStock manageStock = new ManageStock();

            try
            {
                sqlParameters.Add(new KeyValuePair <string, string>("@Type", Type));
                sqlParameters.Add(new KeyValuePair <string, string>("@Code", Code));
                ds = manageSQLConnection.GetDataSetValues("GetCommodityPB", sqlParameters);
                var result = manageStock.GetPhycialBalance(ds);
                return(JsonConvert.SerializeObject(result));
            }
            finally
            {
                ds.Dispose();
            }
        }
Exemple #18
0
        private void SalesForm_Load(object sender, EventArgs e)
        {
            try
            {
                ConnectioString = ConfigurationManager.ConnectionStrings["cns"].ConnectionString;
                mngStock        = new ManageStock(ConnectioString);
                mngSale         = new ManageSale(ConnectioString);
                //List<StockModels> lstStock = mngStock.GetAllStock();
                stockList = mngStock.GetAllStock();
                bindCombobox();
                lblStock.Text = "";

                ChangeBackColor(lblHome);
                picHomeArrow.Visible    = true;
                picInvoiceArrow.Visible = false;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorMessage(ex);
            }
        }
Exemple #19
0
        public string Get(string ITCode1, string ITCode2)
        {
            ManageSQLConnection manageSQLConnection = new ManageSQLConnection();
            DataSet             ds          = new DataSet();
            ManageStock         manageStock = new ManageStock();

            try
            {
                List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >();
                sqlParameters.Add(new KeyValuePair <string, string>("@ITCode1", ITCode1));
                sqlParameters.Add(new KeyValuePair <string, string>("@ITCode2", ITCode2));
                ds = manageSQLConnection.GetDataSetValues("GetDailyStatements", sqlParameters);
                //Convert to list.
                var result = manageStock.GetDailyStockStatments(ds);
                return(JsonConvert.SerializeObject(result));
            }
            finally
            {
                ds.Dispose();
            }
        }
Exemple #20
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Attributes != null?Attributes.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Featured.GetHashCode();
                hashCode = (hashCode * 397) ^ Id;
                hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ InStock.GetHashCode();
                hashCode = (hashCode * 397) ^ ManageStock.GetHashCode();
                hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ OnSale.GetHashCode();
                hashCode = (hashCode * 397) ^ ParentId;
                hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Purchasable.GetHashCode();
                hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ TotalSales;
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Virtual.GetHashCode();
                return(hashCode);
            }
        }
Exemple #21
0
        static void Main(string[] args)
        {
            var stockManager = new ManageStock();

            Console.WriteLine("Welcome to the Guilded Rose Stock Managmenet Program..  ");
            writeHelp();
            bool cont = true;

            while (cont)
            {
                string line = Console.ReadLine();
                switch (line.ToLower())
                {
                case "h":
                    writeHelp();
                    break;

                case "c":
                    cont = false;
                    break;

                case "a":
                    ItemFactory.timer.advanceDay();
                    Console.WriteLine("day advanced");
                    EnterCmd();
                    break;

                case "l":
                    var stock = stockManager.GetStock();
                    Console.WriteLine("Stock found : " + stock.Count);
                    foreach (var item in stock)
                    {
                        Console.WriteLine(item.writeStock());
                    }
                    break;

                default:
                    var list = line.Split(' ');
                    if (list.Length <= 0)
                    {
                        Console.WriteLine("Invalid stock structure - please re-enter");
                    }
                    else
                    {
                        string name = "";
                        int    sellin;
                        int    qual;
                        try
                        {
                            if (list.Length > 3)
                            {
                                // assume our title has a space or two in.
                                qual   = int.Parse(list[list.Length - 1]);
                                sellin = int.Parse(list[list.Length - 2]);
                                var sb = new StringBuilder();
                                for (var i = 0; i < list.Length - 2; i++)
                                {
                                    sb.AppendFormat("{0} ", list[i]);
                                }
                                name = sb.ToString().TrimEnd();
                            }
                            else
                            {
                                qual   = int.Parse(list[2]);
                                sellin = int.Parse(list[1]);
                                name   = list[0].TrimEnd();
                            }

                            stockManager.AddStock(ItemFactory.getStock(name, sellin, qual));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Invalid stock structure - please re-enter");
                        }
                    }
                    break;
                }
                //if (cont) EnterCmd();
            }
            ;
        }
        private void btnManageStock_Click(object sender, RoutedEventArgs e)
        {
            ManageStock manageStock = new ManageStock();

            manageStock.ShowDialog();
        }