public void CreateOnContactRepository()
        {
            //Arrange
            var mockContactNumberRepository = new Mock<IContactNumberRepository>();
            ContactRepository contactRepository = new ContactRepository(_config, mockContactNumberRepository.Object);

            var contactToCreate = new Contact
            {
                UserId = _users[0].Id,
                Title = "Mrs",
                Forename = "Maggie",
                Surname = "Thatcher",
                Email = "*****@*****.**"
            };

            //Act
            Guid id = contactRepository.Create(contactToCreate);

            Contact contact = contactRepository.Get(id);

            //Assert
            Assert.AreEqual(contact, contactToCreate);
            Assert.IsNotNull(id);

            contactRepository.Dispose();
        }
Exemple #2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && repo != null)
     {
         repo.Dispose();
     }
     base.Dispose(disposing);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _contactrepository.Dispose();
     }
     base.Dispose(disposing);
 }
Exemple #4
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                _repository.Dispose();
            }
        }
Exemple #5
0
 public static void TearDownTemporaryObjects()
 {
     //Clean up
     _repo.Dispose();
     File.Delete(_tempDbFilename);
 }
        public void GetOnContactRepository()
        {
            //Arrange
            var mockContactNumberRepository = new Mock<IContactNumberRepository>();
            ContactRepository contactRepository = new ContactRepository(_config, mockContactNumberRepository.Object);

            //Act
            Contact contact = contactRepository.Get(new Guid("81c4763c-b225-4756-903a-750064167813"));

            //Assert
            Assert.AreEqual(_contacts[0], contact);

            contactRepository.Dispose();
        }
        public void GetAllOnContactRepository()
        {
            //Arrange
            var mockContactNumberRepository = new Mock<IContactNumberRepository>();
            ContactRepository contactRepository = new ContactRepository(_config, mockContactNumberRepository.Object);

            //Act
            List<Contact> contacts = contactRepository.GetAll().ToList();

            //Assert
            CollectionAssert.AreEqual(_contacts, contacts);

            contactRepository.Dispose();
        }
        public void UpdateOnContactRepository()
        {
            //Arrange
            var mockContactNumberRepository = new Mock<IContactNumberRepository>();
            ContactRepository contactRepository = new ContactRepository(_config, mockContactNumberRepository.Object);

            var contactToUpdate = _contacts[3];
            contactToUpdate.UserId = new Guid("7b8ceac1-9fb1-4e15-af4b-890b1f0c3ebf");
            contactToUpdate.Forename = "Sean" + "Updated";
            contactToUpdate.Surname = "Baker" + "Updated";
            contactToUpdate.Email = "*****@*****.**" + "Updated";
            contactToUpdate.Title = "Honorable" + "Updated";

            //Act
            contactRepository.Update(contactToUpdate);

            Contact contact = contactRepository.Get(contactToUpdate.Id);

            //Assert
            Assert.AreEqual(contact, contactToUpdate);

            contactRepository.Dispose();
        }