Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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
            }));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }