Exemplo n.º 1
0
        public async Task AddForTest(User user)
        {
            await _db.Users.AddAsync(user);

            _db.Entry(user).State = EntityState.Added;
            await _db.SaveChangesAsync();
        }
        public async Task <IActionResult> Create([Bind("EnvSnapshotId,DateTimeCollected,Temperature,Humidity")] EnvironmentalSnapshot environmentalSnapshot)
        {
            if (ModelState.IsValid)
            {
                environmentalSnapshot.EnvSnapshotId = Guid.NewGuid();
                _context.Add(environmentalSnapshot);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(environmentalSnapshot));
        }
Exemplo n.º 3
0
            public async Task GetLineItemsTest()
            {
                /// ARRANGE
                var lineItem1 = new LineItem
                {
                    LineItemId         = Guid.NewGuid(),
                    StaticPowderInfoId = powderInfo.StaticPowderInfoId,
                    StaticPowderInfo   = powderInfo,
                    PowderOrder        = powderOrderGood,
                    PowderOrderId      = powderOrderGood.PowderOrderId,
                    ParticleSizeMin    = 1,
                    ParticleSizeMax    = 2,
                    VendorDescription  = "",
                };

                _db.LineItems.Add(lineItem1);
                await _db.SaveChangesAsync();

                var lineItem2 = new LineItem
                {
                    LineItemId         = Guid.NewGuid(),
                    StaticPowderInfoId = powderInfo.StaticPowderInfoId,
                    StaticPowderInfo   = powderInfo,
                    PowderOrder        = powderOrderBad,
                    PowderOrderId      = powderOrderBad.PowderOrderId,
                    ParticleSizeMin    = 2,
                    ParticleSizeMax    = 3,
                    VendorDescription  = "",
                };

                _db.LineItems.Add(lineItem2);
                await _db.SaveChangesAsync();

                var result = await repo.GetLineItemsFromPowderOrder(powderOrderGood.PowderOrderId);


                /// ASSERT
                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.ToList().Count);
                Assert.AreEqual(lineItem1.LineItemId, result.ToList().FirstOrDefault().LineItemId);
            }