Example #1
0
        public async void VerifyGetBatches(Freshness freshness)
        {
            Batch matchingBatch = getBatch(testProduct1.Id, freshness);

            Freshness nonMatchingFreshness = (freshness == Freshness.Fresh) ? Freshness.ExpiringToday : Freshness.Fresh;
            Batch     nonMatchingBach      = getBatch(testProduct1.Id, nonMatchingFreshness);

            List <Batch> list = new List <Batch>();

            list.Add(matchingBatch);
            list.Add(nonMatchingBach);

            mockDataHandler.Setup(m => m.GetData <Batch>(DataSource.Batches))
            .ReturnsAsync(list);

            IEnumerable <Batch> products = await dataAccess.GetBatches(freshness);

            Assert.True(products.Count() == 1);

            Batch b = products.First();

            Assert.Equal(testProduct1.Id, b.ProductId);
            Assert.Equal(matchingBatch.Id, b.Id);

            mockDataHandler.Verify(m => m.GetData <Batch>(DataSource.Products), Times.Never);
            mockDataHandler.Verify(m => m.GetData <Batch>(DataSource.Batches), Times.Once);
            mockDataHandler.Verify(m => m.GetData <Batch>(DataSource.BatchEvents), Times.Never);
        }
Example #2
0
 private void oldCheckBox_Checked(object sender, RoutedEventArgs e)
 {
     Speech.speakPurge(null);
     freshness = Freshness.Old;
     if ((bool)newCheckBox.IsChecked)
     {
         newCheckBox.IsChecked = false;
     }
 }
Example #3
0
        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.N && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                if (freshness != Freshness.None)
                {
                    seen[1] = true;
                    Speech.speakPurge(null);
                    Dispatcher.BeginInvoke((ThreadStart) delegate
                    {
                        new Candidate3(candidate, subject, freshness, seen).Show();
                    }, DispatcherPriority.Normal);


                    Dispatcher.BeginInvoke((ThreadStart) delegate { this.Close(); },
                                           DispatcherPriority.Normal);
                }
                else
                {
                    Speech.speakPurge("Please choose freshness to continue");
                }
            }
            else if (e.Key == Key.B && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                Speech.speakPurge(null);
                backButton_Click(null, null);
            }
            else if (e.Key == Key.H && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                Speech.speakPurge("Test Freshness Selection");
                Speech.speakNormal("Press one for new test");
                Speech.speakNormal("or Press two for old test");
                Speech.speakNormal("Then Press N to continue");
            }
            else if (e.Key == Key.S && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                Speech.speakPurge(null);
                signoutButton_Click(null, null);
            }
            else if (e.Key == Key.D1 || e.Key == Key.NumPad1)
            {
                Speech.speakPurge(null);
                freshness             = Freshness.New;
                newCheckBox.IsChecked = true;
            }
            else if (e.Key == Key.D2 || e.Key == Key.NumPad2)
            {
                Speech.speakPurge(null);
                freshness             = Freshness.Old;
                oldCheckBox.IsChecked = true;
            }
            else if (e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                Speech.changeVoice();
            }
        }
Example #4
0
    private Test test; //selected test

    public Candidate3(Candidate candidate, Subject subject, Freshness freshness, bool[] seen)
    {
      this.candidate = candidate;
      this.subject = subject;
      this.freshness = freshness;
      this.seen = seen;

      InitializeComponent();
      setWindowProperties();
    }
Example #5
0
        private Test test;           //selected test

        public Candidate3(Candidate candidate, Subject subject, Freshness freshness, bool[] seen)
        {
            this.candidate = candidate;
            this.subject   = subject;
            this.freshness = freshness;
            this.seen      = seen;

            InitializeComponent();
            setWindowProperties();
        }
Example #6
0
        public void VerifyExpired()
        {
            Batch b = new Batch();

            b.Expiration = DateTime.UtcNow.AddDays(-1);

            Freshness f = b.Freshness;

            Assert.IsTrue(f == Freshness.Expired);
        }
Example #7
0
        public void VerifyExpiresToday()
        {
            Batch b = new Batch();

            b.Expiration = DateTime.UtcNow.AddHours(10);

            Freshness f = b.Freshness;

            Assert.IsTrue(f == Freshness.ExpiringToday);
        }
Example #8
0
        /// <summary>
        /// Get all Batches in the Inventory which still have available portions and
        /// have the given Freshness.
        /// </summary>
        /// <param name="freshness">Freshness of the batches.</param>
        /// <returns>
        /// A Task which will resolve into an IEnumerable of Products.
        /// </returns>
        public async Task <IEnumerable <Batch> > GetBatches(Freshness freshness)
        {
            IEnumerable <Batch> allBatches = await DataHandler.GetData <Batch>(DataSource.Batches);

            IEnumerable <Batch> batches = allBatches.Where(
                b => b.Freshness == freshness
                );

            return(batches);
        }
Example #9
0
        public Candidate4(Candidate candidate, Test test, Freshness freshness)
        {
            this.candidate = candidate;
            this.freshness = freshness;

            InitializeComponent();
            InitializeAnswerGrids();
            setWindowProperties();

            InitializeTestSolver(test);
        }
Example #10
0
    public Candidate4(Candidate candidate, Test test, Freshness freshness)
    {
      this.candidate = candidate;
      this.freshness = freshness;

      InitializeComponent();
      InitializeAnswerGrids();
      setWindowProperties();

      InitializeTestSolver(test);
    }
        public async void VerifyGetBatchesByFreshness(Freshness freshness)
        {
            mockAccessService.Setup(a => a.GetBatches(freshness))
            .ReturnsAsync(batchList);

            ActionResult actionResult = await this.controller.GetBatchesByFreshness(freshness);

            OkObjectResult objResult = Assert.IsType <OkObjectResult>(actionResult);

            Assert.Equal(200, objResult.StatusCode);
            mockAccessService.Verify(a => a.GetBatches(freshness), Times.Once);
        }
Example #12
0
 /// <summary>
 /// Add the content of the given batch to the corresponding Dictionary entries.
 /// </summary>
 /// <param name="batch">
 /// Batch to be added.
 /// </param>
 public void AddBatchesToOverview(List <Batch> batches)
 {
     batches.ForEach(
         batch =>
     {
         Freshness f = batch.Freshness;
         // Add one Batch to the proper category
         BatchesByFreshness[f] += 1;
         // Add the available portions to the proper category
         PortionsByFreshness[f] += batch.AvailableQuantity;
     });
 }
Example #13
0
        private bool[] seen;         //boolean seen array of windows to speak different messages on windows

        public Candidate1(Candidate candidate, Subject subject, Freshness freshness, bool[] seen)
        {
            this.candidate = candidate;
            this.subject   = subject;
            this.freshness = freshness;
            this.seen      = seen;

            InitializeComponent();
            setWindowProperties();

            checkCheckBoxes();
            this.welcomeLabel.Content = "WELCOME " + candidate.UserName;
        }
Example #14
0
    private bool[] seen; //boolean seen array of windows to speak different messages on windows

    public Candidate1(Candidate candidate, Subject subject, Freshness freshness, bool[] seen)
    {
      this.candidate = candidate;
      this.subject = subject;
      this.freshness = freshness;
      this.seen = seen;

      InitializeComponent();
      setWindowProperties();

      checkCheckBoxes();
      this.welcomeLabel.Content = "WELCOME " + candidate.UserName;
    }
Example #15
0
        internal static string ToSerializedValue(this Freshness value)
        {
            switch (value)
            {
            case Freshness.Day:
                return("Day");

            case Freshness.Week:
                return("Week");

            case Freshness.Month:
                return("Month");
            }
            return(null);
        }
Example #16
0
        private Batch getBatch(Guid productId, Freshness freshness)
        {
            Batch b = Batch.GetInstance(productId, 1000);

            if (freshness == Freshness.Expired)
            {
                b.Expiration = DateTime.UtcNow.AddDays(-7);
            }
            else if (freshness == Freshness.ExpiringToday)
            {
                b.Expiration = DateTime.UtcNow.AddHours(6);
            }
            else
            {
                b.Expiration = DateTime.UtcNow.AddDays(7);
            }

            return(b);
        }
Example #17
0
 private void oldCheckBox_Checked(object sender, RoutedEventArgs e)
 {
   Speech.speakPurge(null);
   freshness = Freshness.Old;
   if ((bool)newCheckBox.IsChecked) newCheckBox.IsChecked = false;
 }
Example #18
0
 private void Window_KeyUp(object sender, KeyEventArgs e)
 {
   if (e.Key == Key.N && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
   {
     if (freshness != Freshness.None)
     {
       seen[1] = true;
       Speech.speakPurge(null);
       Dispatcher.BeginInvoke((ThreadStart)delegate
       {
           new Candidate3(candidate, subject, freshness, seen).Show();
       }, DispatcherPriority.Normal);
                 
                
       Dispatcher.BeginInvoke((ThreadStart)delegate { this.Close(); }, 
         DispatcherPriority.Normal);
     }
     else
     {
       Speech.speakPurge("Please choose freshness to continue");
     }
   }
   else if (e.Key == Key.B && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) 
   {
     Speech.speakPurge(null);
     backButton_Click(null, null);
   }
   else if (e.Key == Key.H && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
   {
     Speech.speakPurge("Test Freshness Selection");
     Speech.speakNormal("Press one for new test");
     Speech.speakNormal("or Press two for old test");
     Speech.speakNormal("Then Press N to continue");
   }
   else if (e.Key == Key.S && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
   {
     Speech.speakPurge(null);
     signoutButton_Click(null, null);
   }
   else if (e.Key == Key.D1 || e.Key == Key.NumPad1)
   {
     Speech.speakPurge(null);
     freshness = Freshness.New;
     newCheckBox.IsChecked = true;
   }
   else if (e.Key == Key.D2 || e.Key == Key.NumPad2)
   {
     Speech.speakPurge(null);
     freshness = Freshness.Old;
     oldCheckBox.IsChecked = true;
   }
   else if (e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
   {
     Speech.changeVoice();
   }
 }
Example #19
0
        public async Task <ActionResult> GetBatchesByFreshness([FromRoute] Freshness freshness)
        {
            IEnumerable <Batch> batches = await AccessService.GetBatches(freshness);

            return(Ok(batches));
        }
Example #20
0
 //Конструктор
 public Flower(int price, Freshness fresh, int stem)
 {
     Price      = price;
     Fresh      = fresh;
     StemLength = stem;
 }
Example #21
0
 //Конструктор
 public Iris(int price, Freshness fresh, int stem) : base(0, fresh, stem)
 {
     Price = price;
 }