Beispiel #1
0
        private void CreationOfTestCasesAndMock()
        {
            _mediator          = A.Fake <IMediator>();
            _contactController = new ContactController(_mediator);

            _contactCreateReturned = new ContactV1
            {
                Firstname         = "Arthur",
                Lastname          = "Picaud",
                Fullname          = "Arthur Picaud",
                Address           = "18 rue Colbert Lille",
                Email             = "*****@*****.**",
                MobilePhoneNumber = "+33 7 89 73 78 62"
            };
            _createContactValid = new CreateContactRequestV1
            {
                Firstname         = "Arthur",
                Lastname          = "Picaud",
                Address           = "18 rue Colbert Lille",
                Email             = "*****@*****.**",
                MobilePhoneNumber = "+33 7 89 73 78 62"
            };
            _createContactWithInvalidMail = new CreateContactRequestV1
            {
                Firstname         = "Arthur",
                Lastname          = "Picaud",
                Address           = "18 rue Colbert Lille",
                Email             = "badRegex",
                MobilePhoneNumber = "+33 7 89 73 78 62"
            };
            _updateContact = new UpdateContactRequestV1
            {
                Id                = 7,
                Firstname         = "James",
                Lastname          = "Bond",
                Address           = "MI6 London",
                Email             = "*****@*****.**",
                MobilePhoneNumber = "00 70 07 00 70"
            };
            _contactUpdateReturned = new ContactV1
            {
                Firstname         = "James",
                Lastname          = "Bond",
                Fullname          = "James Bond",
                Address           = "MI6 London",
                Email             = "*****@*****.**",
                MobilePhoneNumber = "00 70 07 00 70"
            };
        }
Beispiel #2
0
        public async Task <ActionResult <ContactV1> > Put(int id, [FromBody] UpdateContactRequestV1 contact)
        {
            if (id != contact.Id)
            {
                return(BadRequest("The id in parametter is different from the id inside the contact"));
            }

            try
            {
                return(await _mediator.Send(contact));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }