Exemplo n.º 1
0
        public void LRE_Agency_Test_With_More_Than_200_Meters_Coordinates()
        {
            //Arrange
            var databaseProperty = new Property()
            {
                AgencyCode = "AE101",
                Latitude   = 32.950888,
                Longitude  = 148.665204
            };

            var agencyProperty = new Property()
            {
                AgencyCode = "AE101",
                Latitude   = -19.823827,
                Longitude  = 133.742410
            };

            var provider = AgencyFactory.GetProvider("LRE");

            //Action
            var result = provider.IsMatch(agencyProperty, databaseProperty);

            //Assert
            Assert.IsFalse(result);
        }
Exemplo n.º 2
0
        public void LRE_Agency_Test_With_Matching_Property()
        {
            //Arrange
            var databaseProperty = new Property()
            {
                AgencyCode = "21212er222",
                Latitude   = -33.9014586,
                Longitude  = 151.206287
            };

            var agencyProperty = new Property()
            {
                AgencyCode = "21212er222",
                Latitude   = -33.901191,
                Longitude  = 151.207628
            };

            var provider = AgencyFactory.GetProvider("LRE");

            //Action
            var result = provider.IsMatch(agencyProperty, databaseProperty);

            //Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 3
0
        public void DestroyAgency_GivenANullAgency_ThrowsArgumentException()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);

            agencyFactory.DestroyAgency(null);
        }
Exemplo n.º 4
0
        public void CreateChildAgency_WithNullAgencyType_ThrowsArgumentException()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var parentAgency     = new Mock <Agency>();

            agencyFactory.CreateChildAgency(new AgencyProfileBuilder().WithAgencyName(
                                                new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object);
        }
Exemplo n.º 5
0
        public void CreateAgency_NullAgencyType_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);

            AgencyProfile agencyProfileWithoutAgencyType = new AgencyProfileBuilder().WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfileWithoutAgencyType);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create the TriTech Testing Agency
        /// </summary>
        /// <returns>The Id of the Agency.</returns>
        public static Guid Create(string implementation, string classicRmsConnectionString)
        {
            // Create the Agency
            var agencyId = AgencyFactory.Create(implementation, "TriTech Testing Agency", "TRI911912", classicRmsConnectionString);

            // Setup Default Roles
            DefaultRoles.Setup(agencyId);

            return(agencyId);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create the TriTech Development Agency
        /// </summary>
        /// <returns>The Id of the Agency.</returns>
        public static Guid Create(string implementation, string classicRmsConnectionString)
        {
            // Create the Development Agency
            var agencyId = AgencyFactory.Create(implementation, "Johnson City Police Department", "TN0900100", classicRmsConnectionString);

            // Setup Default Roles
            DefaultRoles.Setup(agencyId);

            return(agencyId);
        }
Exemplo n.º 8
0
        public void CreateAgency_WhitespaceLegalName_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var agencyType       = new Mock <AgencyType>();

            AgencyProfile agencyProfileWithWhitespaceLegalName =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName("   "));

            agencyFactory.CreateAgency(agencyProfileWithWhitespaceLegalName);
        }
Exemplo n.º 9
0
        public void Invalid_Agency_Provider_Test()
        {
            //Arrange
            string invalid_Agency_provider = "DHL";

            //Action
            var provider = AgencyFactory.GetProvider(invalid_Agency_provider);

            //Assert
            Assert.IsNull(provider);
        }
Exemplo n.º 10
0
        public void CreateAgency_WithValidArguments_CreatesAnAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var agencyType       = new Mock <AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            var agency = agencyFactory.CreateAgency(agencyProfile);

            Assert.IsNotNull(agency);
        }
Exemplo n.º 11
0
        public override CommandExecutionResult Execute()
        {
            try
            {
                // Create the Agency
                AgencyFactory.Create(Implementation, Name, Ori, ClassicRmsConnectionString);
            }
            catch (Exception ex)
            {
                return(CommandExecutionResult.Exception(ex));
            }

            return(CommandExecutionResult.Ok("Complete."));
        }
Exemplo n.º 12
0
        public void DestroyAgency_GivenAnAgency_AgencyIsMadeTransient()
        {
            bool isTransient = false;

            var agencyRepository = new Mock <IAgencyRepository>();

            agencyRepository.Setup(a => a.MakeTransient(It.IsAny <Agency>())).Callback(() => isTransient = true);
            var agencyFactory = new AgencyFactory(agencyRepository.Object);
            var agency        = new Mock <Agency>();

            agencyFactory.DestroyAgency(agency.Object);

            Assert.IsTrue(isTransient);
        }
Exemplo n.º 13
0
        public void CreateChildAgency_WithParentAgency_CreatesAChildAgency()
        {
            var agencyRepository = new Mock <IAgencyRepository>();
            var agencyFactory    = new AgencyFactory(agencyRepository.Object);
            var parentAgency     = new Mock <Agency>();
            var agencyType       = new Mock <AgencyType>();

            Agency agency =
                agencyFactory.CreateChildAgency(
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object);

            Assert.AreSame(agency.ParentAgency, parentAgency.Object);
        }
Exemplo n.º 14
0
        public void CreateAgency_WithValidArguments_AgencyIsMadePersistent()
        {
            bool isPersistent = false;

            var agencyRepository = new Mock <IAgencyRepository>();

            agencyRepository.Setup(a => a.MakePersistent(It.IsAny <Agency>())).Callback(() => isPersistent = true);
            var agencyFactory = new AgencyFactory(agencyRepository.Object);

            var agencyType = new Mock <AgencyType>();

            AgencyProfile agencyProfile =
                new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

            agencyFactory.CreateAgency(agencyProfile);

            Assert.IsTrue(isPersistent);
        }
Exemplo n.º 15
0
        public void CreateChildAgency_WithParentAgency_AgencyIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var agencyRepository = new Mock <IAgencyRepository>();
                var agencyFactory    = new AgencyFactory(agencyRepository.Object);
                var parentAgency     = new Mock <Agency>();
                var agencyType       = new Mock <AgencyType>();

                Agency agency = agencyFactory.CreateChildAgency(
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(LegalName)), parentAgency.Object);

                agency.ReviseAgencyProfile(new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                                               new AgencyNameBuilder().WithLegalName(LegalName).WithDisplayName("My Agency Display Name")));
            }
        }
Exemplo n.º 16
0
        public void CRE_Agency_Test_With_Different_Name()
        {
            //Arrange
            var databaseProperty = new Property()
            {
                Name = "The Summit Apartments"
            };

            var agencyProperty = new Property()
            {
                Name = "The Nice Apartments"
            };

            var provider = AgencyFactory.GetProvider("CRE");

            //Action
            var result = provider.IsMatch(agencyProperty, databaseProperty);

            //Assert
            Assert.IsFalse(result);
        }
Exemplo n.º 17
0
        public void OTBRE_Agency_Test_With_Non_Matching_Name_Address()
        {
            //Arrange
            var databaseProperty = new Property()
            {
                Name    = "Super High Apartments, Sydney",
                Address = "32 Sir John Young Crescent, Sydney NSW"
            };

            var agencyProperty = new Property()
            {
                Name    = "*Super*-High! APARTMENTS (Sydney)",
                Address = "32 Sir John-Young Crescent, Sydney, NSW."
            };
            var provider = AgencyFactory.GetProvider("OTBRE");

            //Action
            var result = provider.IsMatch(agencyProperty, databaseProperty);

            //Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 18
0
        public IActionResult MatchPropert([FromBody] PropertyComparerDTO comparer)
        {
            if (comparer == null)
            {
                return(BadRequest());
            }

            if (comparer.AgencyProperty == null || comparer.DatabaseProperty == null || string.IsNullOrEmpty(comparer.Provider))
            {
                return(BadRequest());
            }

            var provider = AgencyFactory.GetProvider(comparer.Provider);

            if (provider == null)
            {
                return(BadRequest($"{comparer.Provider} is invalid provider"));
            }
            bool result = provider.IsMatch(_mapper.Map <Property>(comparer.AgencyProperty), _mapper.Map <Property>(comparer.DatabaseProperty));

            return(Ok(result));
        }
Exemplo n.º 19
0
        public void OTBRE_Agency_Test_With_Matching_Address()
        {
            //Arrange
            var databaseProperty = new Property()
            {
                Name    = "New Court High Apartments, Sydney",
                Address = "32 Lumely Crescent, Sydney NSW"
            };

            var agencyProperty = new Property()
            {
                Name    = "*Super*-High! APARTMENTS (Sydney)",
                Address = "32 Lumely Crescent, Sydney, NSW."
            };
            var provider = AgencyFactory.GetProvider("OTBRE");

            //Action
            var result = provider.IsMatch(agencyProperty, databaseProperty);

            //Assert
            Assert.IsFalse(result);
        }