コード例 #1
0
        private void ThrowExceptionWhenContactIdIsZeroWhileGet()
        {
            //Act
            var obj = new Appl.Contacts(_loggerMocked.Object, _mapperMocked.Object, _contactRepoMocked.Object);

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

            //Assert
            contacts.Should().NotBeNull();
        }
コード例 #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));
        }
コード例 #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());
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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
            }));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }