コード例 #1
0
 public void Should_throw_error_when_expiry_date_is_less_than_15_days()
 {
     try
     {
         target.AddMedicine(new Medicine {
             ExpiryDate = DateTime.Now
         });
         Assert.Fail("Exception not thrown");
     }
     catch (Exception x)
     {
         Assert.AreSame("Expiry Date is less than 15 days", x.Message);
     }
 }
        private void DodajLek(object sender, RoutedEventArgs e)
        {
            Medicine newMedicine = GenerateMedicineObjectFromCollectedData();

            _medicineController.AddMedicine(newMedicine);
            MessageBox.Show("Lek poslat lekaru na validaciju!", "Čekanje na validaciju", MessageBoxButton.OK);
            _parent.UpdateTable();
            this.Close();
        }
コード例 #3
0
        public void AddMedicineTest()
        {
            var medicine = _fixture.Build <Medicine>().Create();

            _medicinesManager.Setup(s => s.SaveNewMedicine(medicine)).Returns(medicine);
            var response = _controller.AddMedicine(medicine);

            response.ShouldBeOfType(typeof(OkObjectResult));
            var result = response as OkObjectResult;

            result.StatusCode.HasValue.ShouldBeTrue();
            result.StatusCode.Value.ShouldBe((int)HttpStatusCode.OK);
        }
コード例 #4
0
        public void ShouldAddMedicine()
        {
            var mockService = new Mock <IMedicineRepository>();
            //mockService.Setup(x => x.AddMedicineDetails(It.IsAny<Medicine>()));
            var medicineController = new MedicineController(mockService.Object);

            Medicine m = new Medicine();

            m.Name       = "Drug4";
            m.Price      = 14;
            m.Quantity   = 200;
            m.ExpiryDate = new DateTime(2020, 11, 12);
            m.Brand      = "Brand1";

            medicineController.AddMedicine(m);

            mockService.Verify(x => x.AddMedicineDetails(It.IsAny <Medicine>()), Times.Once);
        }
コード例 #5
0
        public void AddMedicineTest()
        {
            var med = new Businessmodel.Medicine()
            {
                Name = "NEWMED", Brand = "NEWBRAND", ExpiryDate = new DateTime(2021, 07, 22).ToString(), Notes = "This is Brand1", Price = 302.08, Quantity = 10
            };

            MedicineBusinesslogicFake.MedicineList.Add(med);
            var mockBL = new Mock <IMedicineBusinesslogic>();

            mockBL.Setup(x => x.AddMedicine(med))
            .Returns(MedicineBusinesslogicFake.MedicineList);

            var controller  = new MedicineController(mockBL.Object);
            var medicineLst = controller.AddMedicine(med);

            Assert.AreEqual("NEWMED", MedicineBusinesslogicFake.MedicineList.Last().Name);
        }
コード例 #6
0
        private async Task Then_AddMedicine()
        {
            var response = await medicineController.AddMedicine(new MedicineEditDto());

            Assert.Equal(StatusCodes.Status201Created, (response as ObjectResult).StatusCode);
        }