예제 #1
0
        public async Task WhenNewDataToBeCreatedThenCheckResponse()
        {
            var createProduct = new MonitoringItems()
            {
                ProductNumber          = "X5",
                ProductName            = "IntelliVue",
                Description            = "The Philips IntelliVue X3 is a compact, dual-purpose, transport patient monitor featuring intuitive SmartPhone-style operation and offering a scalable set of clinical measurements.",
                ProductSpecficTraining = "NO",
                Price    = "14500",
                Wearable = "NO",
                SoftwareUpdateSupport = "YES",
                Portability           = "YES",
                Compact                 = "YES",
                BatterySupport          = "NO",
                ThirdPartyDeviceSupport = "YES",
                SafeToFlyCertification  = "NO",
                TouchScreenSupport      = "YES",
                ScreenSize              = "6.1",
                MultiPatientSupport     = "NO",
                CyberSecurity           = "NO",
                Image = "http://img.com"
            };
            var response = await _sut.Client.PostAsync(url + "/X5",
                                                       new StringContent(JsonConvert.SerializeObject(createProduct), Encoding.UTF8, "application/json"));

            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
예제 #2
0
 public static bool CheckForNullOrMismatchProductNumber(MonitoringItems product, string productNumber)
 {
     if (product == null || product.ProductNumber != productNumber)
     {
         return(true);
     }
     return(false);
 }
        public ActionResult Delete(string productNumber)
        {
            MonitoringItems itemToBeDeleted = Products.Remove(productNumber);

            if (itemToBeDeleted == null)
            {
                return(NotFound());
            }
            return(Ok());
        }
예제 #4
0
        public async Task WhenNewDataIsUpdatedWithADifferentNumberThenCheckTheResponseBadRequest()
        {
            var products = new MonitoringItems()
            {
                ProductName   = "InelVue",
                ProductNumber = "MX480"
            };
            var response = await _sut.Client.PutAsync(url + "/MX40",
                                                      new StringContent(JsonConvert.SerializeObject(products), Encoding.UTF8, "application/json"));

            Assert.True(response.StatusCode == HttpStatusCode.BadRequest);
        }
예제 #5
0
        public async Task WhenExpectedDataIsNotPresentThenCheckTheResponseNotFound()
        {
            var modifyProducts = new MonitoringItems()
            {
                ProductName   = "Inetkhvg",
                ProductNumber = "MX480"
            };
            var response = await _sut.Client.PutAsync(url + "/MX480",
                                                      new StringContent(JsonConvert.SerializeObject(modifyProducts), Encoding.UTF8, "application/json"));

            Assert.True(response.StatusCode == HttpStatusCode.NotFound);
        }
예제 #6
0
        public void UpdateValidObjectPassedReturnsNoContentResult()
        {
            // Arrange-when product object is invalid
            MonitoringItems validMonitoringItem = new MonitoringItems {
                ProductNumber = "MP2", ProductName = "IntelliVue"
            };
            var validProductNumber = "MP2";
            // Act
            var noContentResultResponse = _controller.Update(validProductNumber, validMonitoringItem);

            // Assert
            Assert.IsType <NoContentResult>(noContentResultResponse);
        }
        public IActionResult Create(string productNumber, [FromBody] MonitoringItems product)
        {
            if (ProductConfigureSupporterFunctions.CheckForNullOrMismatchProductNumber(product, productNumber))
            {
                return(BadRequest());
            }

            /*if (product == null)
             * {
             *  return BadRequest();
             * }*/
            Products.Add(product);
            return(Ok());
        }
예제 #8
0
        public void UpdateMisMatchProductNumberPassedReturnsBadRequest()
        {
            // Arrange-when product object is invalid
            MonitoringItems misMatchProductNumberItem = new MonitoringItems()
            {
                ProductNumber = "XYZ",
                ProductName   = "Speaker"
            };
            var productNumber = "XYZA";
            // Act
            var badResponse = _controller.Update(productNumber, misMatchProductNumberItem);

            // Assert
            Assert.IsType <BadRequestResult>(badResponse);
        }
예제 #9
0
        public void UpdateNotExistingProductNumberPassedReturnsNotFound()
        {
            // Arrange-when product object is invalid
            MonitoringItems misMatchProductNumberItem = new MonitoringItems()
            {
                ProductNumber = "M1M2",
                ProductName   = "LCD"
            };
            var productNumber = "M1M2";
            // Act
            var notFoundResponse = _controller.Update(productNumber, misMatchProductNumberItem);

            // Assert
            Assert.IsType <NotFoundResult>(notFoundResponse);
        }
        public string Update(MonitoringItems product)
        {
            var currentProductNumber = product.ProductNumber;

            for (var i = 0; i < MonitoringItems.Count; i++)
            {
                if (MonitoringItems[i].ProductNumber == currentProductNumber)
                {
                    MonitoringItems.RemoveAt(i);
                    MonitoringItems.Add(product);
                    string message = "Updated Successfully";
                    return(message);
                }
            }
            return(null);
        }
예제 #11
0
        public void AddValidObjectPassedReturnsCreatedResponse()
        {
            // Arrange
            MonitoringItems testMonitoringItem = new MonitoringItems()
            {
                ProductNumber = "XXXX",
                ProductName   = "Printer",
                Image         = "imgpath"
            };
            var productNumber = "XXXX";
            // Act
            var createdResponse      = _controller.Create(productNumber, testMonitoringItem);
            var actualResponseObject = createdResponse as OkResult;

            Assert.NotNull(actualResponseObject);
        }
        public IActionResult Update(string productNumber, [FromBody] MonitoringItems product)
        {
            if (ProductConfigureSupporterFunctions.CheckForNullOrMismatchProductNumber(product, productNumber))
            {
                return(BadRequest());
            }
            var currentProduct = Products.Find(productNumber);

            if (currentProduct == null)
            {
                return(NotFound());
            }
            string message = Products.Update(product);

            Console.WriteLine(message);
            return(new NoContentResult());
        }
        public List <MonitoringItems> FilterByCategory(MonitoringItems category)
        {
            var productRepo = new MonitoringProductRepository();
            List <MonitoringItems> product = productRepo.GetAll();

            product = _ifProductSpecficTrainingFilter(category.ProductSpecficTraining, product);
            product = _ifWearableFilter(category.Wearable, product);
            product = _ifSoftwareUpdateSupportFilter(category.SoftwareUpdateSupport, product);
            product = _ifPortabilityFilter(category.Portability, product);
            product = _ifCompactFilter(category.Compact, product);
            product = _ifBatteryFilter(category.BatterySupport, product);
            product = _ifThirdPartyDeviceSupportFilter(category.ThirdPartyDeviceSupport, product);
            product = _ifSafeToFlyCertificationFilter(category.SafeToFlyCertification, product);
            product = _ifTouchScreenFilter(category.TouchScreenSupport, product);
            product = _ifMultiPatientSupportFilter(category.MultiPatientSupport, product);
            product = _ifCyberSecurityFilter(category.CyberSecurity, product);
            product = _ifProductNameFilter(category.ProductName, product);
            product = _ifPriceFilter(category.Price, product);
            product = _ifScreenSizeFilter(category.ScreenSize, product);
            return(product);
        }
예제 #14
0
        public void GetFilterResultReturnOkResult()
        {
            var product = new MonitoringItems
            {
                ProductSpecficTraining = "NO",
                Price    = "16900",
                Wearable = "NO",
                SoftwareUpdateSupport = "YES",
                Portability           = "YES",
                Compact                 = "YES",
                BatterySupport          = "NO",
                ThirdPartyDeviceSupport = "YES",
                SafeToFlyCertification  = "NO",
                TouchScreenSupport      = "YES",
                ScreenSize              = "6.0",
                MultiPatientSupport     = "NO",
                CyberSecurity           = "NO",
                Image = "http://img.com"
            };
            var okResult = _controller.GetValueByCategory(product);

            // Assert
            Assert.IsType <OkObjectResult>(okResult.Result);
        }
        public async Task WhenUsersFilterByCategory()
        {
            var url     = "http://localhost:5001/api/RespondToQuestions/MonitoringProduct";
            var product = new MonitoringItems
            {
                ProductSpecficTraining = "NO",
                Price    = "16900",
                Wearable = "NO",
                SoftwareUpdateSupport = "YES",
                Portability           = "YES",
                Compact                 = "YES",
                BatterySupport          = "NO",
                ThirdPartyDeviceSupport = "YES",
                SafeToFlyCertification  = "NO",
                TouchScreenSupport      = "YES",
                ScreenSize              = "6",
                MultiPatientSupport     = "NO",
                CyberSecurity           = "NO"
            };
            var response = await _sut.Client.PostAsync(url,
                                                       new StringContent(JsonConvert.SerializeObject(product), System.Text.Encoding.UTF8, "application/json"));

            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
 public void Add(MonitoringItems item)
 {
     MonitoringItems.Add(item);
 }
예제 #17
0
 public void Add(MonitoringItems product)
 {
     MonitoringItems.Add(product);
 }
 public ActionResult <IEnumerable <MonitoringItems> > GetValueByCategory([FromBody] MonitoringItems category)
 {
     return(Ok(Products.FilterByCategory(category)));
 }
        public string GetDescription(string productNumber)
        {
            MonitoringItems monitoringItem = Find(productNumber);

            return(monitoringItem?.Description);
        }