Exemplo n.º 1
0
 void ProcessOrigin(IOrigin origin)
 {
     IOriginItem originItem = origin.GetRootItem ();
     logger.DebugFormat ("Processing Root Origin {0}", originItem.Name);
     ArchiveItem archiveItem = Archive.CreateRootItem (Path.GetFileName (originItem.Name), originItem.Type);
     ProcessOriginItem (archiveItem, originItem);
 }
Exemplo n.º 2
0
        public void FewLinesPositionTest()
        {
            string source = "1\n22\n\n4";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();
            OriginPosition pos;

            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 1));

            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 2) && (pos.CharNumber == 0));

            iReader.MoveNext();
            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 2) && (pos.CharNumber == 2));

            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 3) && (pos.CharNumber == 0));

            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 4) && (pos.CharNumber == 0));

            iReader.MoveNext();
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 4) && (pos.CharNumber == 1));
        }
Exemplo n.º 3
0
        public void PrintFragmentInLine(IFragment fragment)
        {
            IOrigin origin = fragment.Origin;

            System.Console.WriteLine(origin.GetLine(fragment.GetBeginOriginPosition().LineNumber));
            System.Console.WriteLine(GetFragmentInLine(fragment));
        }
 public BookCarRequestModel()
 {
     car_id     = 0;
     customerId = string.Empty;
     customerCurrentPosition     = new DestinationOrigin();
     customerDestinationPosition = new DestinationOrigin();
 }
Exemplo n.º 5
0
        public void BeginLocationOriginTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            Assert.AreSame(iOrigin.Begin.Origin, iOrigin);
        }
Exemplo n.º 6
0
        public void FewLinesFragmentPositionsTest()
        {
            string source = "1\n22\n\n4";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            iReader.MoveNext();
            ILocation loc1 = iReader.CurrentLocation;

            iReader.MoveNext();
            iReader.MoveNext();
            ILocation loc2 = iReader.CurrentLocation;

            iReader.MoveNext();

            IFragment fr = iOrigin.MakeFragment(loc1, loc2);

            Assert.AreEqual(fr.GetBeginOriginPosition(), loc1.GetOriginPosition());
            Assert.AreEqual(fr.GetEndOriginPosition(), loc2.GetOriginPosition());

            iReader.MoveNext();
            iReader.MoveNext();
            ILocation loc3 = iReader.CurrentLocation;

            IFragment fr2 = iOrigin.MakeFragment(loc2, loc3);

            Assert.AreEqual(fr2.GetBeginOriginPosition(), loc2.GetOriginPosition());
            Assert.AreEqual(fr2.GetEndOriginPosition(), loc3.GetOriginPosition());
        }
Exemplo n.º 7
0
        public void FewLinesFragmentTextTest()
        {
            string source = "1\n22\n\n4";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            iReader.MoveNext(); // after '1'
            ILocation loc1 = iReader.CurrentLocation;

            iReader.MoveNext(); // after '\n'
            iReader.MoveNext(); // after '2'
            ILocation loc2 = iReader.CurrentLocation;

            iReader.MoveNext(); // after '2'

            Assert.AreEqual(iOrigin.MakeFragment(loc1, loc2).GetOriginText(), "\n2");

            ILocation loc3 = iReader.CurrentLocation;

            iReader.MoveNext(); // after '\n'
            iReader.MoveNext(); // after '\n'
            ILocation loc4 = iReader.CurrentLocation;

            Assert.AreEqual(iOrigin.MakeFragment(loc3, loc4).GetOriginText(), "\n\n");

            iReader.MoveNext(); // after '4'
            ILocation loc5 = iReader.CurrentLocation;

            Assert.AreEqual(iOrigin.MakeFragment(loc4, loc5).GetOriginText(), "4");
        }
Exemplo n.º 8
0
        public void SettingLocationsTest()
        {
            string source = "012";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            iReader.MoveNext(); // point to first character
            char      char1 = iReader.CurrentCharacter;
            ILocation loc1  = iReader.CurrentLocation;

            iReader.MoveNext(); // second character
            char      char2 = iReader.CurrentCharacter;
            ILocation loc2  = iReader.CurrentLocation;

            iReader.MoveNext(); // third character
            char      char3 = iReader.CurrentCharacter;
            ILocation loc3  = iReader.CurrentLocation;

            // check if setting location works

            iReader.CurrentLocation = loc1; // restore first character
            Assert.AreEqual(char1, iReader.CurrentCharacter);

            iReader.MoveNext(); // go to the second
            Assert.AreEqual(char2, iReader.CurrentCharacter);

            iReader.CurrentLocation = loc3; // restore third
            Assert.AreEqual(char3, iReader.CurrentCharacter);

            Assert.IsFalse(iReader.MoveNext());

            iReader.CurrentLocation = loc2; // restore second character
            Assert.AreEqual(char2, iReader.CurrentCharacter);
        }
        public int calculateDistance(IOrigin _startingPoint, IOrigin _destinationPoint)
        {
            int p1 = Math.Abs(_startingPoint.x - _destinationPoint.x);
            int p2 = Math.Abs(_startingPoint.y - _destinationPoint.y);

            return(p1 + p2);
        }
 public BookCarRequestModel(int _carId, string _customerId, DestinationOrigin _customerCurrentPosition, DestinationOrigin _customerDestinationPosition)
 {
     car_id     = _carId;
     customerId = _customerId;
     customerCurrentPosition     = _customerCurrentPosition;
     customerDestinationPosition = _customerDestinationPosition;
 }
Exemplo n.º 11
0
        private ILocation _lastAcceptingLocation;                // Memento equivalent

        public LexerState(IOrigin origin)
        {
            _sourceReader          = origin.GetReader();
            _currentLocation       = _sourceReader.CurrentLocation;
            _lastAcceptedLocation  = _sourceReader.CurrentLocation;
            _lastAcceptingLocation = _lastAcceptedLocation;
            _tokens = new List <Tuple <IFragment, int> >();
        }
Exemplo n.º 12
0
        public void EmptySourceTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();
            Assert.IsFalse(iReader.MoveNext());
        }
Exemplo n.º 13
0
        public void InitialReaderLocationTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();
            Assert.AreEqual(iOrigin.Begin, iReader.CurrentLocation);
        }
 public virtual bool AreEqual(IOriginModel model, IOrigin entity)
 {
     return(NameableEntityMapper.AreEqual(model, entity)
            // Origin Properties
            && model.CharacterSet == entity.CharacterSet
            // Related Objects
            // <None>
            );
 }
Exemplo n.º 15
0
        void ProcessOrigin(IOrigin origin)
        {
            IOriginItem originItem = origin.GetRootItem();

            logger.DebugFormat("Processing Root Origin {0}", originItem.Name);
            ArchiveItem archiveItem = Archive.CreateRootItem(Path.GetFileName(originItem.Name), originItem.Type);

            ProcessOriginItem(archiveItem, originItem);
        }
 public virtual bool AreEqual(IOriginModel model, IOrigin entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Origin Properties
         && model.CharacterSet == entity.CharacterSet
         // Related Objects
         // <None>
         ;
 }
 protected bool Deactivate(IOrigin entity)
 {
     // Deactivate it
     OriginsRepository.Deactivate(entity);
     // Try to Save Changes
     OriginsRepository.SaveChanges();
     // Finished!
     return(true);
 }
Exemplo n.º 18
0
        public void OneCharacterSourceTest()
        {
            string source = "X";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();
            Assert.IsTrue(iReader.MoveNext());
            Assert.AreEqual('X', iReader.CurrentCharacter);
            Assert.IsFalse(iReader.MoveNext());
        }
Exemplo n.º 19
0
        public void InitialLocationPositionTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);

            OriginPosition pos = iOrigin.Begin.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));
        }
 public virtual IOriginModel MapToModelListing(IOrigin entity, int currentDepth = 1)
 {
     currentDepth++;
     var model = NameableEntityMapper.MapToModelListing<IOrigin, OriginModel>(entity);
     // Origin Properties
     model.CharacterSet = entity.CharacterSet;
     // Related Objects
     // <None>
     // Return Entity
     return model;
 }
        public virtual IOriginModel MapToModelListing(IOrigin entity, int currentDepth = 1)
        {
            currentDepth++;
            var model = NameableEntityMapper.MapToModelListing <IOrigin, OriginModel>(entity);

            // Origin Properties
            model.CharacterSet = entity.CharacterSet;
            // Related Objects
            // <None>
            // Return Entity
            return(model);
        }
 public virtual void MapToEntity(IOriginModel model, ref IOrigin entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Origin Properties
     entity.CharacterSet = model.CharacterSet;
     // Related Objects
     // <None>
     // Associated Objects
     entity.OriginProfiles = model.OriginProfiles?.Where(i => i.Active).Select(OriginProfileMapperExtensions.MapToEntity).ToList();
 }
 public virtual void MapToEntity(IOriginModel model, ref IOrigin entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Origin Properties
     entity.CharacterSet = model.CharacterSet;
     // Related Objects
     // <None>
     // Associated Objects
     entity.OriginProfiles = model.OriginProfiles?.Where(i => i.Active).Select(OriginProfileMapperExtensions.MapToEntity).ToList();
 }
Exemplo n.º 24
0
        public void SetBeginLocationTest()
        {
            string source = "XyZ";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();
            iReader.MoveNext();
            iReader.MoveNext();
            iReader.CurrentLocation = iOrigin.Begin; // set reader before first character
            iReader.MoveNext();
            Assert.AreEqual('X', iReader.CurrentCharacter);
        }
 protected bool Remove(IOrigin entity)
 {
     if (entity == null)
     {
         return(true);
     }                                    // No entity found to remove, consider it passed
     // Remove it
     OriginsRepository.Remove(entity);
     // Try to Save Changes
     OriginsRepository.SaveChanges();
     // Finished!
     return(true);
 }
 public virtual IOriginModel MapToModel(IOrigin entity, int currentDepth = 1)
 {
     currentDepth++;
     var model = NameableEntityMapper.MapToModel<IOrigin, OriginModel>(entity);
     // Origin Properties
     model.CharacterSet = entity.CharacterSet;
     // Related Objects
     // <None>
     // Associated Objects
     model.OriginProfiles = entity.OriginProfiles?.Where(i => i.Active).Select(OriginProfileMapperExtensions.MapToModelLite).ToList();
     // Return Entity
     return model;
 }
Exemplo n.º 27
0
        public void NotEqualLocationsTest()
        {
            string source = "XXX";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            iReader.MoveNext(); // point to first character
            ILocation loc1 = iReader.CurrentLocation;

            iReader.MoveNext(); // second character
            Assert.AreNotEqual(loc1, iReader.CurrentLocation);
        }
        public virtual IOriginModel MapToModel(IOrigin entity, int currentDepth = 1)
        {
            currentDepth++;
            var model = NameableEntityMapper.MapToModel <IOrigin, OriginModel>(entity);

            // Origin Properties
            model.CharacterSet = entity.CharacterSet;
            // Related Objects
            // <None>
            // Associated Objects
            model.OriginProfiles = entity.OriginProfiles?.Where(i => i.Active).Select(OriginProfileMapperExtensions.MapToModelLite).ToList();
            // Return Entity
            return(model);
        }
Exemplo n.º 29
0
        public void SetOneLocationTest()
        {
            string source = "XyZ";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            iReader.MoveNext(); // point to first character
            Assert.AreEqual('X', iReader.CurrentCharacter);
            ILocation loc1 = iReader.CurrentLocation;

            iReader.CurrentLocation = loc1;
            Assert.AreEqual('X', iReader.CurrentCharacter);
        }
Exemplo n.º 30
0
        public void ReadTheWholeSourceTest()
        {
            string source = "I like reading sources!\nEspecially in tests.";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            StringBuilder readString = new StringBuilder();

            while (iReader.MoveNext())
            {
                readString.Append(iReader.CurrentCharacter);
            }
            Assert.AreEqual(source, readString.ToString());
        }
Exemplo n.º 31
0
        public void ReadSourceWithEmptyLinesTest()
        {
            string source = "I \n\nlike reading \nsources!\n\n\nEspecially\nin\n tests.";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            StringBuilder readString = new StringBuilder();

            while (iReader.MoveNext())
            {
                readString.Append(iReader.CurrentCharacter);
            }
            Assert.AreEqual(source, readString.ToString());
        }
Exemplo n.º 32
0
        public void EmptySourcePositionTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            OriginPosition pos = iReader.CurrentLocation.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));

            Assert.IsFalse(iReader.MoveNext());
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));
        }
Exemplo n.º 33
0
        public void FalseMoveNextCallsTest()
        {
            string source = "I like reading sources!\nEspecially in tests.";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            while (iReader.MoveNext())
            {
                ;
            }
            Assert.IsFalse(iReader.MoveNext());
            Assert.IsFalse(iReader.MoveNext());
            Assert.IsFalse(iReader.MoveNext());
        }
Exemplo n.º 34
0
        public void OneLineEndPositionTest()
        {
            string source = "1234";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            while (iReader.MoveNext())
            {
                ;
            }

            OriginPosition pos = iReader.CurrentLocation.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 4));
        }
Exemplo n.º 35
0
        public void EmptySourceFragmentTextTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            ILocation loc1 = iReader.CurrentLocation;

            iReader.MoveNext();
            ILocation loc2 = iReader.CurrentLocation;

            IFragment fr = iOrigin.MakeFragment(loc1, loc2);

            Assert.AreEqual(fr.GetOriginText(), "");
        }
Exemplo n.º 36
0
        bool ProcessOrigin(IOrigin origin, VerificationType verificationType)
        {
            bool same = true;

            IOriginItem originItem = origin.GetRootItem ();
            var item = rootItems.SingleOrDefault (p => p.Name == originItem.Name);
            if (item != null) {
                rootItems.Remove (item);
                same = ProcessOriginItem (item, originItem, verificationType);
            } else {
                logger.WarnFormat ("Only present in origin: {0}", item.Name);
                same = false;
            }

            return same;
        }
Exemplo n.º 37
0
 public RestoreEngine(IOrigin origin, Archive archive)
 {
     Origin = origin;
     Archive = archive;
 }
 public static bool AreEqual(this IOriginModel model, IOrigin entity)
 {
     return Mapper.AreEqual(model, entity);
 }
 protected bool Remove(IOrigin entity)
 {
     if (entity == null) { return true; } // No entity found to remove, consider it passed
     // Remove it
     OriginsRepository.Remove(entity);
     // Try to Save Changes
     OriginsRepository.SaveChanges();
     // Finished!
     return true;
 }
 public void Add(IOrigin entity)
 {
     Context.Origins.Add((Origin)entity);
 }
 public void Deactivate(IOrigin entity)
 {
     entity.Active = false;
     Update(entity);
 }
 public void Remove(IOrigin entity)
 {
     Context.Origins.Remove((Origin)entity);
 }
 public void Update(IOrigin entity)
 {
     Context.SetModified(entity);
 }
 protected bool Deactivate(IOrigin entity)
 {
     // Deactivate it
     OriginsRepository.Deactivate(entity);
     // Try to Save Changes
     OriginsRepository.SaveChanges();
     // Finished!
     return true;
 }
 public static void MapToEntity(this IOriginModel model, ref IOrigin entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }