Exemple #1
0
        public void CreateTerritoryCreatesFranchiseeTerritoryWhenEntityTypeIsFranchiseeTerritory()
        {
            var territoryEntity = new TerritoryEntity {
                Type = (byte)TerritoryType.Franchisee
            };

            Territory territory = _territoryFactory.CreateTerritory(territoryEntity);

            Assert.IsInstanceOf <FranchiseeTerritory>(territory);
        }
Exemple #2
0
        public Territory GetTerritory(long territoryId)
        {
            IEnumerable <TerritoryEntity> territoryEntities =
                FetchTerritoryEntities(t => t.TerritoryId == territoryId);
            TerritoryEntity territoryEntity;

            try
            {
                territoryEntity = territoryEntities.Single();
            }
            catch (InvalidOperationException)
            {
                if (territoryEntities.IsEmpty())
                {
                    throw new ObjectNotFoundInPersistenceException <Territory>(territoryId);
                }
                throw new DuplicateObjectException <Territory>();
            }
            return((TerritoryType)territoryEntity.Type == TerritoryType.SalesRep ?
                   GetSalesRepTerritory(territoryEntity) :
                   _territoryFactory.CreateTerritory(territoryEntity));
        }
Exemple #3
0
        public void GetTerritoryPassesFoundTerritoryToFactory()
        {
            var returnedEntity    = new TerritoryEntity();
            var territoryEntities = new EntityCollection <TerritoryEntity> {
                returnedEntity
            };

            ExpectGetDataAccessAdapterAndDispose();
            ExpectLinqFetchEntityCollection(territoryEntities);

            Expect.Call(_territoryFactory.CreateTerritory(returnedEntity)).Return(null);

            _mocks.ReplayAll();
            _territoryRepository.GetTerritory(1);
            _mocks.VerifyAll();
        }