Пример #1
0
        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);
        }
Пример #2
0
 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;
         }
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        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();
        }
Пример #5
0
        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());
        }
Пример #6
0
 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();
 }