Exemplo n.º 1
0
        public void TestPostWithEmptyInValidData()
        {
            AlertDataModel alertDataModel = new AlertDataModel();

            var codereceived = _productsController.Post(alertDataModel);

            Assert.IsType <BadRequestObjectResult>(codereceived);
        }
Exemplo n.º 2
0
 public NotificationView(AlertDataModel consumer)
 {
     InitializeComponent();
     _consumer         = consumer;
     this.Name.Text    = consumer.CustomerName;
     this.Email.Text   = consumer.CustomerEmailId;
     this.Contact.Text = consumer.CustomerContactNo;
     this.Region.Text  = consumer.CustomerRegion;
     this.Product.Text = consumer.ProductIdConfirmed;
 }
Exemplo n.º 3
0
        public void TestPostWithNoCustomerName()
        {
            AlertDataModel alertDataModel = new AlertDataModel()
            {
                CustomerRegion     = "Pune",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P101"
            };
            var codereceived = _productsController.Post(alertDataModel);

            Assert.IsType <BadRequestObjectResult>(codereceived);
        }
Exemplo n.º 4
0
 public async Task GetAllCustomerDetails()
 {
     AlertDataModel data = new AlertDataModel()
     {
         CustomerName       = CustName.Text,
         CustomerContactNo  = CustNo.Text,
         CustomerRegion     = CustRegion.Text,
         CustomerEmailId    = CustEmail.Text,
         ProductIdConfirmed = ProductId.Text
     };
     GetCustomerDetails details = new GetCustomerDetails();
     await details.ProductConfirmation(data);
 }
Exemplo n.º 5
0
        public void TestPostWithInvalidProductIdConfirmed()
        {
            AlertDataModel alertDataModel = new AlertDataModel()
            {
                CustomerName       = "tom",
                CustomerContactNo  = "8765432078",
                CustomerRegion     = "Pune",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P2309"
            };
            var codereceived = _productsController.Post(alertDataModel);

            Assert.IsType <BadRequestObjectResult>(codereceived);
        }
Exemplo n.º 6
0
        public void TestPostWithValidData()
        {
            AlertDataModel alertDataModel = new AlertDataModel()
            {
                CustomerName       = "Tom",
                CustomerContactNo  = "8765432019",
                CustomerRegion     = "Pune",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P101"
            };
            var codereceived = _productsController.Post(alertDataModel);

            Assert.IsType <OkObjectResult>(codereceived);
        }
Exemplo n.º 7
0
        public async Task TestPostWhenCustomerConfirmsProduct()
        {
            var customer = new AlertDataModel()
            {
                CustomerName       = "Jack",
                CustomerContactNo  = "9876543210",
                CustomerEmailId    = "*****@*****.**",
                CustomerRegion     = "Aurangabad",
                ProductIdConfirmed = "P103"
            };
            var response = await _test.Client.PostAsync(url + "/ConfirmationAlert",
                                                        new StringContent(JsonConvert.SerializeObject(customer), Encoding.UTF8, "application/json"));

            response.EnsureSuccessStatusCode();
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Exemplo n.º 8
0
        public void TestGetCustomer()
        {
            AlertDataModel alertDataModel = new AlertDataModel()
            {
                CustomerName       = "Tom",
                CustomerContactNo  = "8765432019",
                CustomerRegion     = "Pune",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P101"
            };

            _productsController.Post(alertDataModel);

            var datareceived = _productsController.Get();

            Assert.NotEmpty(datareceived);
        }
Exemplo n.º 9
0
        public void TestWhenThereAreNoCustomersOfSpecificRegion()
        {
            AlertDataModel alertDataModel = new AlertDataModel()
            {
                CustomerName       = "Tom",
                CustomerContactNo  = "8765432019",
                CustomerRegion     = "Pune",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P101"
            };

            _productsController.Post(alertDataModel);

            var datareceived = _productsController.Get("Mumbai");

            Assert.IsType <NotFoundObjectResult>(datareceived);
        }
Exemplo n.º 10
0
        public async void Test14()
        {
            GetCustomerDetails alert = new GetCustomerDetails();
            AlertDataModel     data  = new AlertDataModel()
            {
                CustomerName       = "Niki",
                CustomerContactNo  = "98765430",
                CustomerRegion     = "South",
                CustomerEmailId    = "*****@*****.**",
                ProductIdConfirmed = "P106"
            };
            await alert.ProductConfirmation(data);

            string notification = GetCustomerDetails.notification;
            string expected     = "";

            Assert.Equal(expected, notification);
        }
Exemplo n.º 11
0
        public async Task ProductConfirmation(AlertDataModel dataModel)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:5000/");
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            var json = JsonConvert.SerializeObject(dataModel);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("api/alert/confirmationAlert", data);

            if (response.IsSuccessStatusCode)
            {
                var jsonContent = response.Content.ReadAsStringAsync().Result;
                notification = jsonContent;
            }
            else
            {
                notification = "";
                MessageBox.Show("Error Code" +
                                response.StatusCode + " : Message - " + response.ReasonPhrase);
            }
        }
Exemplo n.º 12
0
 public void Add(AlertDataModel dataModel)
 {
     _alertsdb.Add(dataModel);
 }