Exemple #1
0
        public void Are_Equal_Size_Returns_True_If_Arrays_Are_Equal_Length()
        {
            var array1   = new byte[] { 1, 2, 3, 5, 6 };
            var array2   = new byte[] { 2, 4, 5, 6, 7 };
            var areEqual = array1.Length == array2.Length;

            Assert.AreEqual(DiffChecker.AreEqualSize(array1, array2), areEqual);
        }
Exemple #2
0
        public void Returns_Diff_When_Two_Arrays_Passed()
        {
            var array1 = new byte[] { 1, 2, 3, 4 };
            var array2 = new byte[] { 1, 4, 5, 6 };

            var diff = DiffChecker.GetDiff(array1, array2);

            Assert.AreEqual(typeof(List <Tuple <int, string, string> >), diff.Results.GetType());
            Assert.AreEqual(diff.Results.Count, 3);
        }
Exemple #3
0
        public void Returns_Diff_When_Two_Base64_String_Are_Passed()
        {
            var string1        = "Simple String 1";
            var encodedString1 = Convert.ToBase64String(Encoding.ASCII.GetBytes(string1));

            var string2        = "Simple String 2";
            var encodedString2 = Convert.ToBase64String(Encoding.ASCII.GetBytes(string2));

            var diff = DiffChecker.GetDiff(encodedString1, encodedString2);

            Assert.AreEqual(typeof(List <Tuple <int, string, string> >), diff.Results.GetType());
            Assert.AreEqual(diff.Results.Count, 1);
        }
 public IHttpActionResult Get()
 {
     try
     {
         if (_streams?.Count > 0)
         {
             var diffMap = DiffChecker.GetDiff(_streams[LeftKey], _streams[RightKey]);
             _streams.Clear();
             return(Ok(diffMap));
         }
         return(BadRequest());
     }
     catch
     {
         return(BadRequest());
     }
 }
        public void Fetch()
        {
            using (var uow = (IUnitOfWork)_services.GetService(typeof(IUnitOfWork)))
            {
                var sportRepository = uow.GetRepository <Sport>();

                //can be stored in memory and update it after each feed pull
                var currentSport = sportRepository
                                   .FirstOrDefault(x => x.Id == SoccerId,
                                                   include: x =>
                                                   x.Include(sp => sp.Events)
                                                   .ThenInclude(ev => ev.Matches)
                                                   .ThenInclude(ma => ma.Bets)
                                                   .ThenInclude(bet => bet.Odds));

                //var updatedSport = _feed.GetSports(SoccerId);
                var updatedSport      = XmlUtils.Deserialize <XmlSportsModel>(XmlUtils.GetXmlString("soccer.xml"));
                var currentSportModel = _mapper.Map <SportModel>(currentSport);

                if (currentSport == null)// Initial DB seed
                {
                    var newSport = _mapper.Map <Sport>(updatedSport.Sport);
                    sportRepository.Add(newSport);
                }
                else
                {
                    var syncRequirement = DiffChecker.GetSyncRequirement(currentSportModel.Events, updatedSport.Sport.Events);
                    if (syncRequirement.IsSyncRequired)
                    {
                        //this is the proper way for db Sync
                        //eventRepository.Sync(updatedEventEntities);

                        // this is a workaround on Sync method. For more info check README.md
                        SyncEventInDb(currentSport, updatedSport.Sport, syncRequirement, uow);
                    }
                }

                uow.BulkSaveChanges();
            }
        }