示例#1
0
        // GET: Equipment
        public ActionResult Index()
        {
            EquipmentService service = NewMethod();
            var model = service.GetEquipments();

            return(View(model));
        }
        public void Initialize_equipment_transfer_return_destination_room_number_because_of_created_examiantion()
        {
            EquipmentService equipmentService = SetupEquipmentService();
            int result = equipmentService.InitializeEquipmentTransfer(_createTransferEqupmentDTO.CreateInvalidTestObjectForInitializingEquipmentTransfer2());

            Assert.Equal(15, result);
        }
        public void Get_alternative_appointments1()
        {
            EquipmentService equipmentService = SetupEquipmentService();
            List <DateTime>  result           = equipmentService.GetAlternativeAppointments(_createTransferEqupmentDTO.CreateInvalidTestObjectForInitializingEquipmentTransfer1());

            Assert.Equal(10, result.Count);
        }
示例#4
0
        private EquipmentService CreateEquipmentService()
        {
            var userId = Guid.Parse(User.Identity.GetUserId());
            var svc    = new EquipmentService(userId);

            return(svc);
        }
        public void Delete(EquipmentDTO equipment)
        {
            IWindowManager manager = new WindowManager();

            EquipmentService.Delete(equipment);
            Reload();
        }
        public async Task GetAllTest()
        {
            var equipment1 = new Equipment()
            {
                Id = 1, Name = "test equipment 1", Price = 20000, RoomId = 1
            };
            var equipment2 = new Equipment()
            {
                Id = 2, Name = "test equipment 2", Price = 30000, RoomId = 2
            };
            var equipments = new List <Equipment> {
                equipment1, equipment2
            };

            var fakeEquipmentRepositoryMock = new Mock <IEquipmentRepository>();
            var fakeRoomRepositoryMock      = new Mock <IRoomRepository>();

            fakeEquipmentRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(equipments);

            var equipmentService = new EquipmentService(fakeEquipmentRepositoryMock.Object, fakeRoomRepositoryMock.Object);

            var resultEquipmentes = await equipmentService.GetAllEquipments();

            Assert.Collection(resultEquipmentes, equipment =>
            {
                Assert.Equal(20000, equipment.Price);
            },
                              equipment =>
            {
                Assert.Equal(30000, equipment.Price);
            });
        }
示例#7
0
        //GET All Equipment
        public IHttpActionResult Get()
        {
            EquipmentService equipmentService = CreateEquipmentService();
            var equipment = equipmentService.GetEquipment();

            return(Ok(equipment));
        }
示例#8
0
        public void AssignStandardBundleToEmployeeUsingMoq_EmployeeId_ReturnsCorrectEmployee()
        {
            var employeeId = Guid.NewGuid();

            var testItem = new EquipmentItem {
                Name = "Test"
            };

            var testBundle = new EquipmentBundle();

            testBundle.Add(testItem);

            var bundleFactoryMock = new Mock <IEquipmentBundleFactory>();

            bundleFactoryMock.Setup(x => x.CreateStandardBundle()).Returns(testBundle);

            var testEmployee = new Employee {
                EmployeeId = employeeId, Bundle = testBundle
            };

            var employeeServiceMock = new Mock <IEmployeeService>();

            employeeServiceMock.Setup(x => x.Connect(It.IsAny <Guid>(), It.IsAny <EquipmentBundle>())).Returns(testEmployee);

            var auditServiceMock = new Mock <IAuditService>();

            var service = new EquipmentService(bundleFactoryMock.Object, employeeServiceMock.Object, auditServiceMock.Object);

            var result = service.AssignStandardBundleToEmployee(employeeId);

            Assert.Equal(employeeId, result.EmployeeId);
            Assert.Single(result.Bundle.Items);
            auditServiceMock.Verify(v => v.WriteEmployeeInfo(It.Is <Employee>(e => e == testEmployee)));
        }
示例#9
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);
        }
示例#10
0
        public void GetEquipmentsPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_Equipment> list = new List <R_Equipment>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleEquipment(i));
            }

            // create mock for repository
            var mock = new Mock <IEquipmentRepository>();

            mock.Setup(s => s.GetEquipments(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            EquipmentService equipmentService = new EquipmentService();

            EquipmentService.Repository = mock.Object;

            // Act
            var          resultList = equipmentService.GetEquipments(searchTerm, pageIndex, pageSize);
            EquipmentDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.EquipmentId);
            Assert.AreEqual(10, resultList.Count);
        }
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         EquipmentService catService = new EquipmentService();
         Equipment        eq         = catService.GetById(id);
         eq.Id   = id;
         eq.Name = textBox5.Text;
         eq.Cost = Convert.ToDouble(textBox4.Text);
         int result = catService.update(eq);
         if (result > 0)
         {
             MessageBox.Show("Equipment updated.");
             UpdateGridView();
         }
         else
         {
             MessageBox.Show("Error");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error!");
     }
 }
示例#12
0
        public void GetEquipments_Success_Test()
        {
            // Arrange
            R_Equipment equipment = SampleEquipment(1);

            IList <R_Equipment> list = new List <R_Equipment>();

            list.Add(equipment);

            // create mock for repository
            var mock = new Mock <IEquipmentRepository>();

            mock.Setup(s => s.GetEquipments()).Returns(list);

            // service
            EquipmentService equipmentService = new EquipmentService();

            EquipmentService.Repository = mock.Object;

            // Act
            var          resultList = equipmentService.GetEquipments();
            EquipmentDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.EquipmentId);
        }
            public void WhenEquipmentExists_ShouldUpdateSuccessfully(int id, string name)
            {
                using (var factory = new SqlLiteDbContextFactory())
                {
                    using (var context = factory.CreateContext())
                    {
                        SetupTestData(context);

                        var service = new EquipmentService(context);

                        var equipment = new Equipment()
                        {
                            Id   = id,
                            Name = name
                        };
                        service.Update(equipment);

                        var updatedEquipment = service.FindById(id);

                        Assert.NotNull(updatedEquipment);
                        Assert.Equal(updatedEquipment.Id, id);
                        Assert.Equal(updatedEquipment.Name, name);
                    }
                }
            }
示例#14
0
 public EquipmentController(IWebHostEnvironment hostingEnvironment, UserService userService, EquipmentService equipmentService, QRCodeService qRCodeService)
 {
     _userService        = userService;
     _equipmentService   = equipmentService;
     _hostingEnvironment = hostingEnvironment;
     _qRCodeService      = qRCodeService;
 }
        public async Task UpdateAndSaveTest()
        {
            var equipment1 = new Equipment()
            {
                Id = 1, Name = "test equipment 1", Price = 20000, RoomId = 1
            };
            var equipment2 = new Equipment()
            {
                Id = 2, Name = "test equipment 2", Price = 30000, RoomId = 2
            };
            var equipments = new List <Equipment> {
                equipment1, equipment2
            };

            var newEquipment2 = new Equipment()
            {
                Id = 2, Name = "test equipment 2", Price = 40000, RoomId = 2
            };

            var fakeEquipmentRepositoryMock = new Mock <IEquipmentRepository>();
            var fakeRoomRepositoryMock      = new Mock <IRoomRepository>();

            fakeEquipmentRepositoryMock.Setup(x => x.Update(It.IsAny <Equipment>())).Callback <Equipment>(arg => equipments[1] = arg);

            var equipmentService = new EquipmentService(fakeEquipmentRepositoryMock.Object, fakeRoomRepositoryMock.Object);

            await equipmentService.UpdateAndSave(newEquipment2);

            Assert.Equal(40000, equipments[1].Price);
        }
 public StockItemController(AuthenticationService authenticationService, LogService logService, StockItemService stockItemService, EquipmentService equipmentService)
 {
     _authenticationService = authenticationService;
     _logService            = logService;
     _stockItemService      = stockItemService;
     _equipmentService      = equipmentService;
 }
        public async Task DeleteAndSaveTest()
        {
            var equipment1 = new Equipment()
            {
                Id = 1, Name = "test equipment 1", Price = 20000, RoomId = 1
            };
            var equipment2 = new Equipment()
            {
                Id = 2, Name = "test equipment 2", Price = 30000, RoomId = 2
            };
            var equipments = new List <Equipment> {
                equipment1, equipment2
            };

            var fakeEquipmentRepositoryMock = new Mock <IEquipmentRepository>();
            var fakeRoomRepositoryMock      = new Mock <IRoomRepository>();

            fakeEquipmentRepositoryMock.Setup(x => x.Delete(It.IsAny <long>())).Callback <long>(arg => equipments.RemoveAt(1));

            var equipmentService = new EquipmentService(fakeEquipmentRepositoryMock.Object, fakeRoomRepositoryMock.Object);

            await equipmentService.DeleteAndSave(equipment2.Id);

            Assert.Single(equipments);
            Assert.Equal(20000, equipments[0].Price);
        }
示例#18
0
 public MainWindow()
 {
     InitializeComponent();
     _equipmentService = new EquipmentService();
     _brandService     = new BrandService();
     _toolService      = new ToolService();
 }
        public async Task AddAndSaveTest()
        {
            var equipment1 = new Equipment()
            {
                Id = 1, Name = "test equipment 1", Price = 20000, RoomId = 1
            };
            var equipment2 = new Equipment()
            {
                Id = 2, Name = "test equipment 2", Price = 30000, RoomId = 2
            };
            var equipments = new List <Equipment> {
                equipment1, equipment2
            };

            var equipment3 = new Equipment()
            {
                Id = 2, Name = "test equipment 3", Price = 40000, RoomId = 2
            };

            var fakeEquipmentRepositoryMock = new Mock <IEquipmentRepository>();
            var fakeRoomRepositoryMock      = new Mock <IRoomRepository>();

            fakeEquipmentRepositoryMock.Setup(x => x.Add(It.IsAny <Equipment>())).Callback <Equipment>(arg => equipments.Add(arg));

            var equipmentService = new EquipmentService(fakeEquipmentRepositoryMock.Object, fakeRoomRepositoryMock.Object);

            await equipmentService.AddAndSave(equipment3);


            Assert.Equal(3, equipments.Count);
        }
示例#20
0
        Task <bool> IRequestHandler <UpdateChecklistEquipmentRequest, bool> .Handle(UpdateChecklistEquipmentRequest request, CancellationToken cancellationToken)
        {
            var existingChecklistEquipment = EquipmentService.Get(request.ChecklistEquipment.Id);

            if (existingChecklistEquipment == null)
            {
                throw new ApplicationException($"UpdateChecklistEquipmentHandler: ChecklistEquipment with Id {request.ChecklistEquipment.Id} does not exist.");
            }

            //var checkDuplicate = EquipmentService.GetEquipmentByChecklistAndRigId(request.ChecklistEquipment.RigId, request.ChecklistEquipment.OapChecklistId, request.ChecklistEquipment.OapEquipmentId);
            //if (checkDuplicate != null)
            //{
            //    throw new ApplicationException($"UpdateChecklistEquipmentHandler: ChecklistEquipment with Id {request.ChecklistEquipment.Id} already exist.");
            //}

            //AutoMapper to Map the fields
            Mapper.Map(request.ChecklistEquipment, existingChecklistEquipment);

            using (var ts = new TransactionScope())
            {
                var updatedChecklistEquipment = EquipmentService.Update(existingChecklistEquipment);

                ts.Complete();
            }
            return(Task.FromResult(true));
        }
示例#21
0
        //GET Equipment by Id
        public IHttpActionResult Get(int id)
        {
            EquipmentService svc = CreateEquipmentService();
            var equipment        = svc.GetEquipmentById(id);

            return(Ok(equipment));
        }
示例#22
0
        //-------------------------------------------------------------------------------------------------//

        public Specification(Configuration configuration, EquipmentService equipmentServiceProxy)
            : base(configuration, equipmentServiceProxy)
        {
            const string STRLOG_MethodName = "Specification";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Save these for use by the Parse() method
            //
            this.configuration = configuration;

            //
            // Check that the specification template is valid. This is used by the LabClient to submit
            // the experiment specification to the LabServer for execution.
            //
            try
            {
                //
                // Check that all required XML nodes exist
                //
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_serverUrl, true);
                XmlUtilities.GetXmlValue(this.xmlNodeSpecification, Consts.STRXML_formatName, true);
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
示例#23
0
        public static IEquipmentService Create(Guid tenantId)
        {
            if (Container == null)
            {
                throw new ArgumentNullException("Container", "Unity Container Not Initialized.");
            }

            if (string.IsNullOrEmpty(ConnectionString))
            {
                throw new ArgumentNullException("ConnectionString", "ConnectionString is empty.");
            }

            var iCommonMapper     = Container.Resolve <ICommonMapper>();
            var iCommonRepository = new CommonRepository(new Common_Entities(ConnectionString));
            var tenant            = iCommonRepository.RetrieveTenantById(tenantId);

            iCommonRepository.Dispose();
            if (tenant == null)
            {
                throw new Exception("Could not find schema for this tenantId:" + tenantId);
            }

            var equipmentEntities     = new ANDP_Equipment_Entities(ConnectionString, tenant.Schema);
            var equipmentRepository   = new EquipmentRepository(equipmentEntities);
            IEquipmentService service = new EquipmentService(equipmentRepository, iCommonMapper);

            return(service);
        }
示例#24
0
        Task <bool> IRequestHandler <UpdateEquipmentRequest, bool> .Handle(UpdateEquipmentRequest request, CancellationToken cancellationToken)
        {
            var existingEquipment = EquipmentService.Get(request.Equipment.Name);

            if (existingEquipment == null)
            {
                throw new ApplicationException($"UpdateEquipmentHandler: Equipment with Name {request.Equipment.Name} does not exist.");
            }

            var checkDuplicate = EquipmentService.Get(request.Equipment);

            if (checkDuplicate != null)
            {
                throw new ApplicationException($"UpdateEquipmentHandler: Equipment with Name {request.Equipment.Name} already exist.");
            }

            //AutoMapper to Map the fields
            Mapper.Map(request.Equipment, existingEquipment);

            using (var ts = new TransactionScope())
            {
                var updatedQuestionTagMap = EquipmentService.Update(existingEquipment);

                ts.Complete();
            }
            return(Task.FromResult(true));
        }
        public void Get_existent_equipment_by_valid_room_number()
        {
            EquipmentService _equipmentService = SetupEquipmentService();
            List <Equipment> equipment         = _equipmentService.GetEquipmentByRoomNumber(56);

            Assert.NotNull(equipment);
        }
        public ActionResult Index(int?page)
        {
            IEnumerable <EquipmentDTO> equipmentDTOs = EquipmentService.GetAll().ToList();
            IEnumerable <EquipmentVM>  equipmentVMs  = Mapper.Map <IEnumerable <EquipmentVM> >(equipmentDTOs);

            return(View(equipmentVMs.ToPagedList(page ?? 1, PageSize)));
        }
        public void Initialize_equipment_transfer_valid()
        {
            EquipmentService equipmentService = SetupEquipmentService();
            int result = equipmentService.InitializeEquipmentTransfer(_createTransferEqupmentDTO.CreateValidTestObjectForInitializingEquipmentTransfer());

            Assert.Equal(-1, 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 Get_alternative_appointments2()
        {
            EquipmentService equipmentService = SetupEquipmentService();
            List <DateTime>  result           = equipmentService.GetAlternativeAppointments(_createTransferEqupmentDTO.CreateInvalidTestObjectForInitializingEquipmentTransfer1());

            Assert.DoesNotContain(_createTransferEqupmentDTO.CreateInvalidTestObjectForInitializingEquipmentTransfer1().DateAndTimeOfTransfer, result);
        }
示例#30
0
        private EquipmentService NewMethod()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new EquipmentService(userId);

            return(service);
        }