Ejemplo n.º 1
0
        /// <summary>
        /// Book a plan by register customer
        /// </summary>
        /// <param name="bookPlan"></param>
        /// <returns></returns>
        public async Task <BookedPlan> BookPlan(int planId, Customer customer)
        {
            var plan = _internetDbContext.Plans.Where(x => x.PlanId == planId).FirstOrDefault();

            var booked = new BookedPlan()
            {
                UserName   = customer.UserName,
                CustomerId = customer.CustomerId,
                PlanName   = plan.PlanName,
                Email      = customer.Email,
                Address    = customer.Address
            };

            _internetDbContext.Add(booked);
            await _internetDbContext.SaveChangesAsync();

            return(booked);
        }
Ejemplo n.º 2
0
 public ExceptionalTest()
 {
     //Creating New mock Object with value.
     _internetServices = new InternetProviderServices(service.Object);
     _bookedPlan       = new BookedPlan
     {
         BookedPlanId = 1,
         UserName     = "******",
         CustomerId   = 1,
         PlanName     = "Monthly",
         Email        = "*****@*****.**",
         Address      = "a/3 Banglore"
     };
     _complaint = new Complaint
     {
         ComplaintId = 1,
         Subject     = "Not Working",
         Description = "Internet Plan is not working",
         CustomerId  = 1,
         Email       = "*****@*****.**",
         IsSolved    = false
     };
     _customer = new Customer
     {
         CustomerId   = 1,
         UserName     = "******",
         PhoneNumber  = 9631438121,
         Address      = "a/3 Banglore",
         Email        = "*****@*****.**",
         Age          = 23,
         Region       = "Bihar",
         BusinessType = "Home"
     };
     _plan = new Plan
     {
         PlanId         = 1,
         PlanName       = "Monthly",
         Description    = "Get 30 GB Data",
         PlanExpiryDate = DateTime.Now
     };
 }
Ejemplo n.º 3
0
        public async Task <bool> Testfor_Validate_Invlid_BookPlan()
        {
            //Arrange
            bool res             = false;
            var  _customerUpdate = new Customer
            {
                CustomerId   = 1,
                UserName     = "******",
                PhoneNumber  = 9631438121,
                Address      = "a/3 Banglore",
                Email        = "*****@*****.**",
                Age          = 23,
                Region       = "Bihar",
                BusinessType = "Home"
            };

            _customerUpdate = null;
            //Act
            service.Setup(repo => repo.BookPlan(_plan.PlanId, _customerUpdate)).ReturnsAsync(_bookedPlan = null);
            var result = await _internetServices.BookPlan(_plan.PlanId, _customerUpdate);

            if (result == null)
            {
                res = true;
            }
            //Asert
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_exception_revised.txt", "Testfor_Validate_Invlid_BookPlan=" + res + "\n");

            return(res);
        }