private void ThrowExceptionWhenContactIdIsZeroWhileGet()
        {
            //Act
            var obj = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            //Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => obj.Get(0));
        }
        private void ExecuteConstructor()
        {
            //Act
            var contacts = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            //Assert
            contacts.Should().NotBeNull();
        }
        private void ThrowExceptionWhenIdIsLessthanZeroWhileRemoveAddress()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.Delete(It.IsAny <int>())).Returns(true);
            Assert.Throws <ArgumentOutOfRangeException>(() => contact.Remove(-1));
        }
        private void ThrowExceptionWhenNullZipcode()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.GetAll(It.IsAny <string>())).Returns(_contacts);

            Assert.Throws <ArgumentNullException>(() => contact.GetAll(null).ToList());
        }
        private void RemoveAddress()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.Delete(It.IsAny <int>())).Returns(true);
            var result = contact.Remove(123);

            //Assert
            result.Should().BeTrue();
        }
        private void GetAllWithNoResult()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.GetAll()).Returns(new List <DomainModels.Contact>());

            var contactsResult = contact.GetAll();

            //Assert
            contactsResult.Should().BeNull();
        }
        private void GetResult()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.Get(It.IsAny <int>())).Returns(_contact1);

            var contactResult = contact.Get(1);

            //Assert
            contactResult.Should().NotBeNull();
            contactResult.ContactId.Should().Be(1);
        }
        private void ThrowExceptionWhenLastEmptyWhileAdd()
        {
            //Act
            var obj = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            //Assert
            Assert.Throws <ArgumentException>(() => obj.Add(new ApplModels.Contact
            {
                FirstName    = "FirstName",
                LastName     = string.Empty,
                BusinessName = string.Empty
            }));
        }
        private void GetAllResult()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.GetAll()).Returns(_contacts);

            var contactsResult = contact.GetAll().ToList();

            //Assert
            contactsResult.Should().NotBeNull();
            contactsResult[0].ContactId.Should().Be(1);
            contactsResult[1].ContactId.Should().Be(2);
        }
Exemplo n.º 10
0
        private void AddContactWithBusinessName()
        {
            //Act
            var contacts = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            var result = contacts.Add(new ApplModels.Contact
            {
                FirstName    = string.Empty,
                LastName     = string.Empty,
                BusinessName = BusinessName
            });

            //Assert
            result.BusinessName.Should().Be(BusinessName);
        }
Exemplo n.º 11
0
        private void GetAllByZipcode()
        {
            //Act
            var contact = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            _contactRepoMocked.Setup(repo => repo.GetAll(It.IsAny <string>())).Returns(_contacts);

            var contactsResult = contact.GetAll("12345").ToList();

            //Assert
            contactsResult.Should().NotBeNull();
            contactsResult[0].ContactId.Should().Be(1);
            contactsResult[0].Addresses.Count.Should().Be(1);

            contactsResult[1].ContactId.Should().Be(2);
        }
Exemplo n.º 12
0
        private void AddContactWithFirstAndLastNames()
        {
            //Act
            var contacts = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            var result = contacts.Add(new ApplModels.Contact
            {
                FirstName    = FirstName,
                LastName     = LastName,
                BusinessName = string.Empty
            });

            //Assert
            result.FirstName.Should().Be(FirstName);
            result.LastName.Should().Be(LastName);
        }
Exemplo n.º 13
0
        private void AddContactWithBusinessNameAndAddress()
        {
            //Act
            var contacts = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

            var result = contacts.Add(new ApplModels.Contact
            {
                FirstName    = string.Empty,
                LastName     = string.Empty,
                BusinessName = BusinessName,
                Addresses    = new List <ApplModels.Address> {
                    new ApplModels.Address {
                        Street = "street", City = "city", State = "state", ZipCode = "10001"
                    }
                }
            });

            //Assert
            result.BusinessName.Should().Be(BusinessName);
        }