Пример #1
0
        public List <Order> CheckOrders(DateTime date, ProductTypeRepository repoPr)
        {
            List <Order> ordersOfThisDate = new List <Order>();

            foreach (Order ord in listOfOrders.Values)
            {
                if (date.ToString("yyyy-MM-dd") == ord.Date.ToString("yyyy-MM-dd"))
                {
                    if (repoPr.CheckAmountOfProductsInOrder(ord) == true)
                    {
                        ordersOfThisDate.Add(ord);
                        OnOrderReadyToPackEventArgs args = new OnOrderReadyToPackEventArgs();
                        string email = BuildEmailReadyToPackOrder(ord, repoPr);
                        args.EmailMessage = email;
                        if (orderReadyToPack != null)
                        {
                            orderReadyToPack(this, args);
                        }
                    }
                    else
                    {
                        string email = BuildEmailNotEnoughStock(ord, repoPr);
                        OnAmountNotEnoughEventArgs args = new OnAmountNotEnoughEventArgs();
                        args.EmailMessage = email;
                        if (orderAmountNotEnough != null)
                        {
                            orderAmountNotEnough(this, args);
                        }
                    }
                }
            }

            return(ordersOfThisDate);
        }
Пример #2
0
        public void SendEmailForReadyToBePackedOrder(object o, OnOrderReadyToPackEventArgs args)
        {
            var admin = new User()
            {
                UserName = "******", Password = "******", NumMessagesCreated = 0
            };
            var message = new Mail()
            {
                Content = args.EmailMessage
            };

            var mockMail = new Mock <IMailModule>();

            mockMail.Setup(x => x.SendMail(message, "*****@*****.**")).Callback(() => admin.NumMessagesCreated = 1);

            //Act
            mockMail.Object.SendMail(message, "*****@*****.**");

            if (admin.NumMessagesCreated == 0)
            {
                throw new Exception("COULD NOT SEND MAIL!");
            }
        }