public void TestIsMedicineAlreadyExistFalse() { var med = new Medicine() { Manufacturer = "test", Name = "test", ProductForm = "test" }; IRepository <Medicine> medRep = Mock.Of <IRepository <Medicine> >(d => d.GetAll() == new List <Medicine>() { new Medicine() { Name = "test1", Manufacturer = "test1", ProductForm = "test" } }.AsQueryable() ); Assert.IsFalse(ValidationClass.IsMedicineAlreadyExist(med, medRep)); }
public void TestIsMedicineAlreadyExistTrue() { var med = new Medicine() { Manufacturer = "test", Name = "test", ProductForm = "test" }; IRepository <Medicine> medRep = Mock.Of <IRepository <Medicine> >(d => d.GetAll() == new List <Medicine>() { new Medicine() { Name = "test", Manufacturer = "test", ProductForm = "test" } }.AsQueryable() ); Exception ex = Assert.Throws <Exception>( delegate { ValidationClass.IsMedicineAlreadyExist(med, medRep); }); Assert.That(ex.Message, Is.EqualTo("Такое лек.средство уже существует в системе!")); }