public void ClearButton_Test() { // Arrange string validDeviceName = "Panel KTP900 Basic"; string validArticleNumber = "DSF98-DS9F8-DS98F"; string validSelectedProducerName = "SIEMENS"; string validLocation = "A2"; int validQuantity = 13; var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.DeviceName = validDeviceName; newDeviceVM.ArticleNumber = validArticleNumber; newDeviceVM.SelectedProducerName = validSelectedProducerName; newDeviceVM.Location = validLocation; newDeviceVM.Quantity = validQuantity; // Act newDeviceVM.ClearButton(); // Assert Assert.Equal("", newDeviceVM.DeviceName); Assert.Equal("", newDeviceVM.ArticleNumber); Assert.Equal("", newDeviceVM.Location); Assert.Equal(0, newDeviceVM.Quantity); }
public void SaveNewDevice_Test() { // Arrange string validDeviceName = "Panel KTP900 Basic"; string validArticleNumber = "DSF98-DS9F8-DS98F"; string validSelectedProducerName = "SIEMENS"; string validLocation = "A2"; int validQuantity = 13; var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.DeviceName = validDeviceName; newDeviceVM.ArticleNumber = validArticleNumber; newDeviceVM.SelectedProducerName = validSelectedProducerName; newDeviceVM.Location = validLocation; newDeviceVM.Quantity = validQuantity; // Act newDeviceVM.SaveButton(); // Assert Assert.True(newDeviceVM.NewDeviceValidationResult); Assert.True(newDeviceVM.SaveNewDeviceResult); Assert.IsType <SnackbarMessageQueue>(newDeviceVM.SnackbarNotification.MessageQueue); }
public int AddDevice([FromBody] NewDeviceViewModel deviceViewModel) { var device = new NewDeviceModel(); device.Name = deviceViewModel.Name; device.Type = deviceViewModel.Type; return(this.devicesService.AddDevice(device)); }
public void LoadProducers_Test() { // Arrange var producerNames = GenerateProducersNameList(); // Act var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.LoadProducersRun(); // Assert Assert.IsType <BindableCollection <string> >(newDeviceVM.ProducersName); Assert.True(producerNames.Count == newDeviceVM.ProducersName.Count); }
public ActionResult Create(NewDeviceViewModel vm) { var result = false; using (var repo = new DeviceRepository(_userId)) { result = repo.AddNewDevice(vm); } if (result) { return(RedirectToAction("Index", "Manage")); } ModelState.AddModelError("", "Save error"); return(View()); }
public void SaveNewProducerInvalidData_Test(string name, string url) { // Arrange var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.ProducerName = name; newDeviceVM.URL = url; // Act newDeviceVM.SaveNewProducer(); // Assert Assert.IsType <SnackbarMessageQueue>(newDeviceVM.SnackbarNotification.MessageQueue); Assert.False(newDeviceVM.SaveNewProducerResult); Assert.False(newDeviceVM.NewProducerValidationResult); }
public async Task <IActionResult> AddAsync(NewDeviceViewModel data) { System.Security.Claims.ClaimsPrincipal currentUser = this.User; var user = await _userManager.GetUserAsync(User); if (!ModelState.IsValid) { return(View(data)); } await _deviceServices.AddAsync(data.Manufacturer, data.Model, data.SerialNumber, data.DeviceDescription, data.UserId, data.CategoryId); return(RedirectToAction("Index", "Devices")); }
public void ClearProducerForm_Test() { // Arrange string validProducerName = "FESTO"; string validProducerURL = "https://festo.com/"; var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.ProducerName = validProducerName; newDeviceVM.URL = validProducerURL; // Act newDeviceVM.ClearProducerForm(); // Assert Assert.Equal("", newDeviceVM.ProducerName); Assert.Equal("", newDeviceVM.URL); }
public void SaveNewDeviceInvalidData_Test(string deviceName, string articleNumber, string producerName, string location, int quantity) { // Arrange var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.DeviceName = deviceName; newDeviceVM.ArticleNumber = articleNumber; newDeviceVM.SelectedProducerName = producerName; newDeviceVM.Location = location; newDeviceVM.Quantity = quantity; // Act newDeviceVM.SaveButton(); // Assert Assert.IsType <SnackbarMessageQueue>(newDeviceVM.SnackbarNotification.MessageQueue); Assert.False(newDeviceVM.NewDeviceValidationResult); Assert.False(newDeviceVM.SaveNewDeviceResult); }
public void SaveNewProducer_Test() { // Arrange string validProducerName = "FESTO"; string validProducerURL = "https://festo.com/"; var newDeviceVM = new NewDeviceViewModel(_producerAccess, _deviceAccess); newDeviceVM.ProducerName = validProducerName; newDeviceVM.URL = validProducerURL; // Act newDeviceVM.SaveNewProducer(); // Assert Assert.Equal(validProducerName, newDeviceVM.ProducerName); Assert.Equal(validProducerURL, newDeviceVM.URL); Assert.IsType <SnackbarMessageQueue>(newDeviceVM.SnackbarNotification.MessageQueue); Assert.True(newDeviceVM.SaveNewProducerResult); Assert.True(newDeviceVM.NewProducerValidationResult); }
public bool AddNewDevice(NewDeviceViewModel vm) { var newDevice = _context.UserDevices.Add(_modelFactory.Create(vm, _userId)); return(newDevice != null ? true : false); }