public void Add_NameIsMandatory_Fail() { // arrange var equipment = new Equipment(); var response = new Response <Equipment>() { ErrorMessage = "Name is mandatory" }; // act var result = _equipmentService.Add(equipment); // assert _assertHelper.Assertion(response, result); }
public void Add() { if (!IsEdit) { string x = EquipmentService.Add(Name, SelectedEquipmentType?.Id, Quantity, Description, IsAvailable); if (x == null) { TryClose(); } else { Error = x; } } else { toEdit.Name = Name; toEdit.Quantity = Quantity; toEdit.Description = Description; toEdit.IsAvailable = IsAvailable; toEdit.EquipmentTypeId = SelectedEquipmentType.Id; string x = EquipmentService.Edit(toEdit); if (x == null) { TryClose(); } else { Error = x; } } }
public void TestAdd() { var mockSet = new Mock <DbSet <Equipment> >(); mockSet.Setup(s => s.Create()) .Returns(() => { Mock <Equipment> mock = new Mock <Equipment>(); return(mock.Object); }); var mockContext = new Mock <InventoryControlContext>(); mockContext.Setup(m => m.Set <Equipment>()).Returns(mockSet.Object); var mockRepository = new Mock <EquipmentRepository>(); var service = new EquipmentService(mockRepository.Object); service.Add(new Equipment() { Code = "abcdef", DateAcquisition = DateTime.Now, ModelEquipment = "modelo", TypeEquipment = "tipo", ValueAcquisition = 1000 }); var equip = service.GetByCode("abcdef"); Assert.IsTrue(equip != null); }
public void Add() { var newEquipment = new EquipmentDTO(); newEquipment.Type = Type; newEquipment.Mark = Mark; newEquipment.Model = Model; newEquipment.AddDate = AddDate; newEquipment.Status = Status; EquipmentService.Add(newEquipment); TryClose(); }
public void TestAdd() { var equipmentVO = new EquipmentVO() { Name = "name1", NextControlDate = new System.DateTime(2020, 06, 06), Picture = new byte[0], SerialNumber = 1 }; _equipmentService.Add(equipmentVO); _mockEquipmentRepository.Verify(m => m.Add(It.IsAny <Equipment>()), Times.Once()); }
public void Add() { if (IsEdit == true) { ToEdit.Type = Type; ToEdit.Mark = Mark; ToEdit.Model = Model; ToEdit.AddDate = AddDate; ToEdit.Status = Status; EquipmentService.Edit(ToEdit); } else { var newEquipment = new EquipmentDTO(); newEquipment.Type = Type; newEquipment.Mark = Mark; newEquipment.Model = Model; newEquipment.AddDate = AddDate; newEquipment.Status = Status; EquipmentService.Add(newEquipment); } TryClose(); }