public async Task GetMedicineByID() { // Arrange var medicineBusinessLayer = this.CreateMedicineBusinessLayer(); // var objectsList = new List<DataModel.Medicine>(); // var objectsListBusiness = new List<BusinessModel.Medicine>(); var medicineID = Guid.NewGuid(); // Act DataModel.Medicine medi = new DataModel.Medicine { Brand = "Cipla", ExpiryDate = new System.DateTime(), Id = medicineID, Name = "Dolo", Notes = "Should be taken in Fever", Price = 100.00M, Quantity = 100 }; BusinessModel.Medicine med = new BusinessModel.Medicine { Brand = "Cipla", ExpiryDate = new System.DateTime(), Id = medicineID, Name = "Dolo", Notes = "Should be taken in Fever", Price = 100.00M, Quantity = 100 }; BusinessModel.Medicine medical = null; //objectsListBusiness.Add(med); this.mockMedicineInfo.Setup(x => x.GetMedicineByID(It.IsAny <Guid>())).Returns(Task.FromResult <DataModel.Medicine>(medi)); this.mapper.Setup(m => m.Map <DataModel.Medicine, BusinessModel.Medicine>(It.IsAny <DataModel.Medicine>())).Returns(med); var result = await medicineBusinessLayer.GetMedicineByID(medicineID); // Assert Assert.AreEqual(result, medical); }
public async Task <bool> SaveMedicine(BusinessModel.Medicine medicine) { if (medicine.Id == null || medicine.Id == Guid.Empty) { medicine.Id = Guid.NewGuid(); } DataModel.Medicine med = mapper.Map <DataModel.Medicine>(medicine); return(await _medicineInfo.SaveMedicine(med)); }
public async Task <BusinessModel.Medicine> GetMedicineByID(Guid medicineID) { DataModel.Medicine medicine = await _medicineInfo.GetMedicineByID(medicineID); return(mapper.Map <BusinessModel.Medicine>(medicine)); }