示例#1
0
        static void Main(string[] args)
        {
            //string url = "./geth.ipc";

            //int start = 500599;
            //int end = 1000000;
            //bool postVm = true;


            string url    = args[0];
            int    start  = Convert.ToInt32(args[1]);
            int    end    = Convert.ToInt32(args[2]);
            bool   postVm = false;

            if (args.Length > 3)
            {
                if (args[3].ToLower() == "postvm")
                {
                    postVm = true;
                }
            }

            string prefix           = "Morden";
            string connectionString =
                "DefaultEndpointsProtocol=https;AccountName=ujostorage;AccountKey=DPGFO3b/lkkMLCD6jy495ZZzUSkgcCaPS1/ue1HnpS9ewuOgtHErurN8bhSm960cYD0oWRTXW/86njdNkvS2ZQ==";

            var proc = new StorageProcessor(url, start, end, connectionString, prefix, postVm);
            // proc.Init().Wait();
            var result = proc.ExecuteAsync().Result;

            Debug.WriteLine(result);
            System.Console.WriteLine(result);
            System.Console.ReadLine();
        }
 public void CheckDocumentCountIsZero()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
     long count =  sp.Count();
     Assert.AreEqual (0, count);
     }
 }
 public void InitialiseStorageProcessor100Times()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
         for (int i = 0; i < 100; i++) {
             sp.Initialise();
         }
     }
     Assert.IsTrue(true);
 }
        static void Main(string[] args)
        {
            ServiceCollection serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);
            IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            var url = "http://localhost:8545";

            var processor = new StorageProcessor(url, unitOfWork);

            while (true)
            {
                new Helpers().AddLog(LogType.Info, "Processing Blockchain");
                var result = processor.ExecuteAsync();
                Task.WaitAll(result);
            }
        }
        public void Inser100DocumentsDelete100DocumentsInsert100CheckFileSizeIsSameAsAfterDelete()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();
                for (int i = 1; i < 101; i++) {
                    sp.Store<PersonEntity>(new PersonEntity() { Id = i, Name = "Test", Email = "Test" });
                    #if DEBUG
                    Console.WriteLine("File Size: " + sp.FileSize);
                    #endif
                }

                // store file size for the assert
                long fileSize = sp.FileSize;
                for (int i = 1; i < 101; i++) {
                    sp.Delete(i);
                    #if DEBUG
                    Console.WriteLine("File Size: " + sp.FileSize);
                    #endif
                }
                Assert.AreEqual(fileSize, sp.FileSize);

                // store another documet file size should be the same.
                for (int i = 1; i < 101; i++) {
                    sp.Store<PersonEntity>(new PersonEntity() { Id = i, Name = "Test", Email = "Test" });
                    #if DEBUG
                    Console.WriteLine("File Size: " + sp.FileSize);
                    #endif
                }
                Assert.AreEqual(fileSize, sp.FileSize);
            }
        }
        public void StoreThreeDocumentsLoadFirstDocument()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();

                var person = new PersonEntity() { Name = "Test 2", Email = "Test 2" };
                sp.Store<PersonEntity>(person);
             	sp.Store<PersonEntity>(new PersonEntity() { Name = "Test 1", Email = "Test 1" });

                var loadPerson =  sp.Load<PersonEntity>(person.Id);

            Assert.AreEqual (person.Id, loadPerson.Id);
            }
        }
        public void StoreThreeDocumentsDeleteOneDocumentLoadDeletedDocumentReturnsNull()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();

             var person = new PersonEntity() { Name = "Test 2", Email = "Test 2" };
             sp.Store<PersonEntity>(person);
             sp.Store<PersonEntity>(new PersonEntity() { Name = "Test 1", Email = "Test 1" });
             sp.Delete(person.Id);

            var loadPerson =  sp.Load<PersonEntity>(person.Id);
            Assert.IsNull(loadPerson);
            }
        }
        public void InsertOneDocumentUpdateDocumentSoRelocatedInsertNewDocumentWithSameSizeCheckFileSizeIsSame()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();

                // insert one record and get file size
                var entity = new PersonEntity() { Name = "Test", Email = "Test" };
                var entity2 = new PersonEntity() { Name = "Test", Email = "Test" };
                sp.Store<PersonEntity>(entity);

                // store file size for the assert
                entity.Name = "1000000hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh";
                sp.Update<PersonEntity>(entity);

                var fileSize = sp.FileSize;
                Assert.AreEqual(fileSize, sp.FileSize);

                // store another documet file size should be the same.
                sp.Store<PersonEntity>(entity2);
                Assert.AreEqual(fileSize, sp.FileSize);
            }
        }
 public void Insert1RecordsCheckCount1RemoveCheckDocumentCountIs0()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
     var person = new PersonEntity() { Name = "Person " + 1, Email = "Email " + 1 };
      sp.Store<PersonEntity>(person);
     Assert.AreEqual(1,  sp.Count());
      sp.Delete(person.Id);
     Assert.AreEqual (0,  sp.Count());
     }
 }
示例#10
0
        public void Insert1RecordChangeDataAndUpdateCheckUpdated()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();
            var person = new PersonEntity() { Name = "Person", Email = "Email" };
             sp.Store<PersonEntity>(person);

                Assert.AreEqual(1,  sp.Count());

            var existingPerson =  sp.Load<PersonEntity>(person.Id);
            existingPerson.Name = "Person With Longer Name";
             sp.Update<PersonEntity>(existingPerson);
            Assert.AreEqual(1,  sp.Count());

            // check updated
            var updatedPerson =  sp.Load<PersonEntity>(person.Id);
            Assert.AreEqual ("Person With Longer Name", updatedPerson.Name);
            }
        }
示例#11
0
        public void Insert100RecordsLoad100CheckAllMatchInserted()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();
                for (int i = 1; i < 101; i++) {
                    sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i });
                    #if DEBUG
                    Console.WriteLine("INSERT: {0}", i);
                    #endif
                }
                long count =  sp.Count();
                Assert.AreEqual (100, count);

                // load
                var records = sp.Load<PersonEntity>();
                int countCheck = 1;
                foreach(var r in records){
                    Assert.AreEqual(r.Name, "Person " + countCheck);
                    Assert.AreEqual(r.Email, "Email " + countCheck);
                    countCheck++;
                }
            }
        }
示例#12
0
        public void Insert100DocumentsCheckDocumentCountIs100()
        {
            using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
            {
                sp.DestroyExistingData();
            for (int i = 1; i < 101; i++) {
                 sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i });
                #if DEBUG
                Console.WriteLine("INSERT: {0}", i);
                #endif
            }
            long count =  sp.Count();
            Assert.AreEqual (100, count);

            }
        }
示例#13
0
 public void Insert10000Documents()
 {
     using (var sp = new StorageProcessor(_dataDirectory, _entity, _serializer))
     {
         sp.DestroyExistingData();
     for (int i = 1; i < 10001; i++) {
          sp.Store<PersonEntity>(new PersonEntity() { Name = "Person " + i, Email = "Email " + i });
         #if DEBUG
         Console.WriteLine("INSERT: {0}", i);
         #endif
     }
     }
     Assert.True (true);
 }
示例#14
0
 public void Init()
 {
     processor = new StorageProcessor();
 }