예제 #1
0
        public async Task UpdateContactReturnsBadRequestIfEmailAlreadyInUse()
        {
            var existingContact = _testContacts.First();

            var contactUpdate = new ApplicationCore.Models.ContactUpdate()
            {
                Id            = existingContact.Id,
                FirstName     = existingContact.FirstName,                                        //not updating
                LastName      = existingContact.LastName,                                         //not updating
                Email         = _testContacts.First(x => x.Email != existingContact.Email).Email, //attempting to update to another Contact's Email
                PhoneNumber   = existingContact.PhoneNumber,                                      //not updating
                ContactStatus = existingContact.ContactStatus                                     //not updating
            };

            var updateResult = await _sutContactService.UpdateContact(contactUpdate);

            Assert.True(updateResult.IsBadRequest); //controller returns 400
        }
예제 #2
0
        public async Task UpdateContactReturnsBadRequestIfNothingChanged()
        {
            var existingContact = _testContacts.First();

            var contactUpdate = new ApplicationCore.Models.ContactUpdate()
            {
                Id            = existingContact.Id,
                FirstName     = existingContact.FirstName,    //not updating
                LastName      = existingContact.LastName,     //not updating
                Email         = existingContact.Email,        //not updating
                PhoneNumber   = existingContact.PhoneNumber,  //not updating
                ContactStatus = existingContact.ContactStatus //not updating
            };

            var updateResult = await _sutContactService.UpdateContact(contactUpdate);

            Assert.True(updateResult.IsBadRequest); //controller returns 400
        }
예제 #3
0
        public async Task UpdateContactReturnsTrueIfSuccessful()
        {
            var existingContact = _testContacts.First();

            var contactUpdate = new ApplicationCore.Models.ContactUpdate()
            {
                Id            = existingContact.Id,
                FirstName     = existingContact.FirstName,                                                       //not updating
                LastName      = existingContact.LastName,                                                        //not updating
                Email         = existingContact.Email,                                                           //not updating
                PhoneNumber   = existingContact.PhoneNumber == "555-111-2222" ? "555-123-4567" : "555-111-2222", //updating PhoneNumber
                ContactStatus = existingContact.ContactStatus                                                    //not updating
            };

            var updateResult = await _sutContactService.UpdateContact(contactUpdate);

            Assert.False(updateResult.IsBadRequest); //controller won't return 400

            Assert.NotNull(updateResult.Data);       //controller won't return 404

            Assert.True(updateResult.Data);          //controller returns 200
        }