Beispiel #1
0
        public ActionResult Post(Buyer model)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(model.FirstName))
                {
                    return(BadRequest("Please enter Name"));
                }
                else if (string.IsNullOrWhiteSpace(model.Email))
                {
                    return(BadRequest("Please enter Email"));
                }
                else if (string.IsNullOrWhiteSpace(model.Address))
                {
                    return(BadRequest("Please enter Address"));
                }

                _buyereservices.RegisterAsync(model);

                return(Ok("Your product has been added successfully"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }
        }
        public async Task <IActionResult> Register(Buyer buyer)
        {
            try
            {
                // TODO: Add insert logic here
                await _service.RegisterAsync(buyer);

                return(RedirectToAction(nameof(AllBuyer)));
            }
            catch
            {
                return(View());
            }
        }
        public async Task ExceptionTest_Failure_BuyerRegistration()
        {
            try
            {
                //Arrange
                Buyer buyer = null;

                Boolean register = await _buyerservices.RegisterAsync(buyer);

                File.AppendAllText("../../../../output_exception_revised.txt", "ExceptionTest_Failure_BuyerRegistration=" + register.ToString() + "\n");

                //   await Assert.ThrowsAsync<ArgumentNullException>(async () => await _buyerservices.RegisterAsync(buyer));
            }catch (Exception)
            {
                File.AppendAllText("../../../../output_exception_revised.txt", "ExceptionTest_Failure_BuyerRegistration= False\n");
            }
        }
Beispiel #4
0
        public async Task TestFor_BuyerRegistration()
        {
            try  {
                //Action
                var registeredBuyer = await _buyerservices.RegisterAsync(buyer);

                var getBuyer = await _buyerservices.GetBuyerByIdAsync(buyer.BuyerId);

                File.AppendAllText("../../../../output_revised.txt", "TestFor_BuyerRegistration=" + registeredBuyer.ToString() + "\n");


                //Assert
                Assert.True(registeredBuyer);
                Assert.Equal(getBuyer, registeredBuyer);
            }catch (Exception)
            {
                File.AppendAllText("../../../../output_revised.txt", "TestFor_BuyerRegistration= False\n");
            }
        }
        public async Task BoundaryTestFor_ValidBuyerIdAsync()
        {
            try
            {
                //Action
                Buyer buyer = new Buyer()
                {
                    BuyerId     = random.Next(1, 300000),
                    FirstName   = "Buyer",
                    LastName    = "user",
                    Email       = "*****@*****.**",
                    Password    = "******",
                    PhoneNumber = 9087654321,
                    Address     = "Delhi",
                    Pincode     = 678490,
                };
                var MinValue = 1;
                var MaxValue = 300000;


                if (buyer.BuyerId < MaxValue && buyer.BuyerId > MinValue)
                {
                    Boolean id = await _buyerservices.RegisterAsync(buyer);

                    File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidBuyerId=" + id.ToString() + "\n");
                }
                else
                {
                    File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidBuyerId= False\n");
                }
            }
            catch (Exception)
            {
                File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidBuyerId= False\n");
            }
        }