Exemple #1
0
 public ServiceChannelLogic(ChannelAttachmentLogic attachmentLogic, WebPageLogic webPageLogic, OpeningHoursLogic openingHoursLogic, AddressLogic addressLogic)
 {
     this.attachmentLogic   = attachmentLogic;
     this.webPageLogic      = webPageLogic;
     this.openingHoursLogic = openingHoursLogic;
     this.addressLogic      = addressLogic;
 }
        public void ShouldGetAddressByUser()
        {
            var expected = _addresses.Where(a => a.UserId == 1).ToList();
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Returns(expected);

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.GetByUser(1);

            Assert.AreEqual(1, result.AddressId);
            Assert.AreEqual(1, result.UserId);
        }
        public void CreateGoogleApiUrl()
        {
            var mockConfig = new Mock <IConfiguration>();
            var validator  = new AddressLogic(mockConfig.Object);

            var newAddy = new Address.Lib.Address
            {
                Id      = new Guid("566e1a61-c283-4d33-9b9b-9a981393cf2b"),
                Street  = "1100 N E St",
                City    = "Arlington",
                State   = "Texas",
                Country = "US",
                ZipCode = "76010"
            };
            var address = validator.FormatAddress(newAddy);
            var result  = validator.GetGoogleApiUrl(address, address);

            Assert.Equal($"?units=imperial&origins={address}&destinations={address}&key=", result);
        }
        public void CheckAddressFormatting()
        {
            var mockConfig = new Mock <IConfiguration>();
            var validator  = new AddressLogic(mockConfig.Object);

            var newAddy = new Address.Lib.Address
            {
                Id      = new Guid("566e1a61-c283-4d33-9b9b-9a981393cf2b"),
                Street  = "1100 N E St",
                City    = "Arlington",
                State   = "Texas",
                Country = "US",
                ZipCode = "76010"
            };

            var result = validator.FormatAddress(newAddy);

            Assert.Equal("1100+N+E+St+Arlington,Texas+76010", result);
        }
Exemple #5
0
        public ServiceTestBase()
        {
            VersioningManagerMock  = new Mock <IVersioningManager>();
            UserIdentificationMock = new Mock <IUserIdentification>();
            CommonServiceMock      = new Mock <ICommonServiceInternal>();

            ExternalSourceRepoMock = new Mock <IExternalSourceRepository>();
            unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IExternalSourceRepository>()).Returns(ExternalSourceRepoMock.Object);

            ConnectionRepoMock = new Mock <IServiceServiceChannelRepository>();
            unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceServiceChannelRepository>()).Returns(ConnectionRepoMock.Object);

            translationManagerMockSetup       = new Mock <ITranslationEntity>();
            translationManagerVModelMockSetup = new Mock <ITranslationViewModel>();

            LockingManager           = (new Mock <ILockingManager>()).Object;
            VersioningManager        = VersioningManagerMock.Object;
            UserOrganizationChecker  = (new Mock <IUserOrganizationChecker>()).Object;
            UserIdentification       = UserIdentificationMock.Object;
            TranslationManagerVModel = translationManagerVModelMockSetup.Object;

            AddressService          = (new Mock <IAddressService>()).Object;
            CommonService           = CommonServiceMock.Object;
            UserInfoService         = (new Mock <IUserInfoService>()).Object;
            UserOrganizationService = (new Mock <IUserOrganizationService>()).Object;
            DataUtils             = new DataUtils();
            ValidationManagerMock = (new Mock <IValidationManager>()).Object;
            PublishedId           = PublishingStatusCache.Get(PublishingStatus.Published);
            DeletedId             = PublishingStatusCache.Get(PublishingStatus.Deleted);
            OldPublishedId        = PublishingStatusCache.Get(PublishingStatus.OldPublished);

            var mapServiceProviderMock = new MapServiceProvider(
                (new Mock <IHostingEnvironment>()).Object,
                new ApplicationConfiguration((new Mock <IConfigurationRoot>()).Object),
                (new Mock <IOptions <ProxyServerSettings> >()).Object,
                new Mock <ILogger <MapServiceProvider> >().Object);

            AddressLogic = new AddressLogic(mapServiceProviderMock);
        }
Exemple #6
0
 public AddressController(AddressLogic _addressMethods)
 {
     addressMethods = _addressMethods;
 }
        public void ShouldThrowExceptionWhenGetAddressByUserFails()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Throws(new Exception());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            Assert.Throws<BlogException>(() => _addressLogic.GetByUser(1));
        }
        public void ShouldErrorWhenGetAddressByUserFoundNoRecord()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Returns(new List<Address>());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.GetByUser(1);

            Assert.IsNotNull(result.Error);
            Assert.AreEqual((int)Constants.Error.RecordNotFound, result.Error.Id);
            Assert.AreEqual("No address found for user with Id 1", result.Error.Message);
        }
        public void ShouldThrowExceptionWhenDeleteAddressFails()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Delete(It.IsAny<Address>())).Throws(new Exception());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            Assert.Throws<BlogException>(() => _addressLogic.Delete(1));
        }
        public void ShouldReturnFalseWhenDeleteAddressFoundNoRecord()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), false))
               .Returns(new List<Address>());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.Delete(1);

            Assert.IsFalse(result);
        }
        public void ShouldReturnTrueOnDeleteAddress()
        {
            var dbResult = new List<Address> { new Address { AddressId = 1 } };
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), false))
               .Returns(dbResult);

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.Delete(1);

            Assert.IsTrue(result);
        }
        public void ShouldThrowExceptionWhenUpdateAddressFails()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Edit(It.IsAny<Address>())).Throws(new Exception());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            Assert.Throws<BlogException>(() => _addressLogic.Update(new Common.Contracts.Address()));
        }
        public void ShouldUpdateAddress()
        {
            var dbResult = new Address
            {
                AddressId = 3,
                StreetAddress = "Wiggle",
                City = "Berry",
                State = "Carrot",
                Country = "Gumbo",
                Zip = 1234,
                UserId = 5,
                User = new User
                {
                    UserId = 5,
                    UserName = "******"
                }
            };
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Edit(It.IsAny<Address>())).Returns(dbResult);

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.Update(new Common.Contracts.Address
            {
                AddressId = 3,
                StreetAddress = "Wiggle",
                City = "Berry",
                State = "Carrot",
                Country = "Gumbo",
                Zip = 1234
            });

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.UserId);
        }
Exemple #14
0
 public OrganizationLogic(ChannelAttachmentLogic attachmentLogic, WebPageLogic webPageLogic, AddressLogic addressLogic)
 {
     this.attachmentLogic = attachmentLogic;
     this.webPageLogic    = webPageLogic;
     this.addressLogic    = addressLogic;
 }