Beispiel #1
0
        public void PostCallAppointment_Ambiguous_CustomerId_In_CustomerBadRequest()
        {
            using (var server = TestServer.Create <MoveManager.Web.Api.App_Start.Startup>())
            {
                var request = new NewAppointmentCallRequest()
                {
                    Appointment = new Model.Appointment()
                    {
                        AgentId    = WebApiHelper.Agent.Create(server),
                        CustomerId = Guid.NewGuid()
                    },
                    Customer = new Model.Customer()
                    {
                        CustomerId = Guid.Empty
                    }
                };

                var response = server.PostRequest("call/appointment", request);

                response.AssertIs(
                    HttpStatusCode.BadRequest,
                    new CommandError()
                {
                    Message = "AgentId cannot be null"
                });
            }
        }
Beispiel #2
0
        public void PostCallAppointment_Empty_Appointment_Not_Existing_AgentId_BadRequest()
        {
            using (var server = TestServer.Create <MoveManager.Web.Api.App_Start.Startup>())
            {
                var request = new NewAppointmentCallRequest()
                {
                    Customer = new Model.Customer()
                    {
                        CustomerId = Guid.Empty,
                        Name       = "Customer.Name",
                    },
                    Appointment = new Model.Appointment()
                    {
                        AgentId = Guid.NewGuid()
                    }
                };

                var response = server.PostRequest("call/appointment", request);

                response.AssertIs(
                    HttpStatusCode.BadRequest,
                    new CommandError()
                {
                    Message = "Invalid Command"
                });
            }
        }
Beispiel #3
0
 public IEither <IEnumerable <ICommandError>, NewAppointmentResponse> NewAppointmentCall(
     NewAppointmentCallRequest newAppointmentCall)
 {
     return
         (this.CreateOrUpdateCustomer(newAppointmentCall.Customer)
          .Right(customer =>
                 this.CreateOrUpdateAppointment(customer.Id, newAppointmentCall.Appointment)
                 .Right(
                     agent => new NewAppointmentResponse
     {
         customer = customer,
         agent = agent
     })));
 }
Beispiel #4
0
        public void PostCallAppointment_Empty_Customer_BadRequest()
        {
            using (var server = TestServer.Create <MoveManager.Web.Api.App_Start.Startup>())
            {
                var request = new NewAppointmentCallRequest()
                {
                };

                var response = server.PostRequest("call/appointment", request);

                response.AssertIs(
                    HttpStatusCode.BadRequest,
                    new CommandError()
                {
                    Message = "Invalid Command"
                });
            }
        }
Beispiel #5
0
 public IHttpActionResult PostCallAppointment(NewAppointmentCallRequest newAppointmentCall)
 {
     try
     {
         return(this.CallService.NewAppointmentCall(newAppointmentCall)
                .Case <IHttpActionResult>(
                    errors => this.Conflict(),
                    newAppointmentResponse => this.Ok(newAppointmentResponse)));
     }
     catch (InvalidCommandException)
     {
         return(this.BadRequest());
     }
     catch (NotExistingAggregate)
     {
         return(this.BadRequest());
     }
     catch (Exception ex)
     {
         return(this.InternalServerError(ex));
     }
 }
Beispiel #6
0
        public void PostCallAppointment_NotExisting_Customer_BadRequest()
        {
            using (var server = TestServer.Create <MoveManager.Web.Api.App_Start.Startup>())
            {
                var request = new NewAppointmentCallRequest()
                {
                    Customer = new Model.Customer()
                    {
                        CustomerId = Guid.NewGuid(),
                    }
                };

                var response = server.PostRequest("call/appointment", request);

                response.AssertIs(
                    HttpStatusCode.BadRequest,
                    new CommandError()
                {
                    Message = $"Not existing entity {request.Customer.CustomerId}"
                });
            }
        }
Beispiel #7
0
        public void PostCallAppointment_New_Customer_Null_Name_Conflict()
        {
            using (var server = TestServer.Create <MoveManager.Web.Api.App_Start.Startup>())
            {
                var request = new NewAppointmentCallRequest()
                {
                    Customer = new Model.Customer()
                    {
                        CustomerId = Guid.Empty,
                        Name       = null,
                    }
                };

                var response = server.PostRequest("call/appointment", request);

                response.AssertIs(
                    HttpStatusCode.Conflict,
                    new CommandError()
                {
                    Message = "Name cannot be empty"
                });
            }
        }