Exemplo n.º 1
0
        /// <summary>
        /// Returns a BatchEvent Instance.
        /// </summary>
        /// <param name="batch">
        /// Batch that has been added.
        /// </param>
        /// <param name="type">
        /// Type of the event.
        /// </param>
        /// <returns>
        /// A BatchEvent instance.
        /// </returns>
        public static BatchEvent GetInstance(Batch batch, BatchEventType type)
        {
            BatchEvent e = new BatchEvent();

            e.EventType         = type;
            e.BatchId           = batch.Id;
            e.EventDate         = DateTime.UtcNow;
            e.AvailableQuantity = batch.AvailableQuantity;
            e.Freshness         = batch.Freshness;
            return(e);
        }
Exemplo n.º 2
0
        public async void VerifyGetBatchHistory(BatchEventType type)
        {
            BatchEvent        e    = BatchEvent.GetInstance(testBatch1, type);
            List <BatchEvent> list = new List <BatchEvent>();

            list.Add(e);

            mockDataHandler.Setup(m => m.GetData <BatchEvent>(DataSource.BatchEvents)).ReturnsAsync(list);

            IEnumerable <BatchEvent> events = await dataAccess.GetBatchHistory(testBatch1.Id);

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

            BatchEvent ev = events.First();

            Assert.Equal(testBatch1.Id, ev.BatchId);

            mockDataHandler.Verify(m => m.GetData <BatchEvent>(DataSource.Products), Times.Never);
            mockDataHandler.Verify(m => m.GetData <BatchEvent>(DataSource.Batches), Times.Never);
            mockDataHandler.Verify(m => m.GetData <BatchEvent>(DataSource.BatchEvents), Times.Once);
        }