コード例 #1
0
    public void TestGetSingleAddress()
    {
      var generator = new AddressGenerator();

      var address = generator.GetAddress(this.seedOne, SecurityLevel.Medium, 0);
      Assert.AreEqual("DLEIS9XU9V9T9OURAKDUSQWBQEYFGJLRPRVEWKN9SSUGIHBEIPBPEWISSAURGTQKWKWNHXGCBQTWNOGIY", address.Value);
      Assert.AreEqual(2, address.SecurityLevel);

      var addressTwo = generator.GetAddress(this.seedOne, SecurityLevel.Medium, 10);
      Assert.AreEqual("XLXFTFBXUOOHRJDVBDBFEBDQDUKSLSOCLUYWGLAPR9FUROUHPFINIUFKYSRTFMNWKNEPDZATWXIVWJMDD", addressTwo.Value);
      Assert.AreEqual(10, addressTwo.KeyIndex);
    }
コード例 #2
0
        protected override void Seed(BookingsDbContext context)
        {
            var random               = new Random();
            var addressGenerator     = new AddressGenerator();
            var userNameGenerator    = new UserNameGenerator();
            var passportGenerator    = new PassportGenerator();
            var cultureCodeGenerator = new CultureGenerator();

            for (int i = 0; i < 8; i++)
            {
                var fromDate = DateTime.Today;
                var toDate   = fromDate.AddDays(random.Next(1, 5));

                context.Bookings.Add(new Booking
                {
                    CustomerId   = "Cust-10" + i,
                    CustomerName = userNameGenerator.GetName(),
                    Address      = addressGenerator.GetAddress(),
                    From         = fromDate,
                    To           = toDate,
                    Passport     = passportGenerator.GetPassport(),
                    Amount       = random.Next(10, 40) * 100,
                    Type         = "CheckIn",
                    Culture      = cultureCodeGenerator.Cultures[random.Next(0, cultureCodeGenerator.Cultures.Count - 1)]
                });
            }

            for (int i = 0; i < 8; i++)
            {
                var fromDate = DateTime.Today.AddDays(random.Next(-5, -2));
                var toDate   = DateTime.Today;

                context.Bookings.Add(new Booking
                {
                    CustomerId   = "Cust-10" + i,
                    CustomerName = userNameGenerator.GetName(),
                    Address      = addressGenerator.GetAddress(),
                    From         = fromDate,
                    To           = toDate,
                    Passport     = passportGenerator.GetPassport(),
                    Amount       = random.Next(10, 40) * 100,
                    Type         = "CheckOut",
                    Culture      = cultureCodeGenerator.Cultures[random.Next(0, cultureCodeGenerator.Cultures.Count - 1)]
                });
            }

            context.SaveChanges();

            base.Seed(context);
        }
コード例 #3
0
        public void generateAddressFromUser(User user, int start, int end)
        {
            var addressGenerator = new AddressGenerator(user.getSeed());

            int i;

            for (i = start; i < end; i++)
            {
                AddressTable addr = new AddressTable()
                {
                    Index            = user.AddressIndex + i,
                    generatedAddress = addressGenerator.GetAddress(user.AddressIndex + i).ToString(),
                    UserID           = user.UserID
                };

                _context.AddressTable.Add(addr);
            }

            user.AddressIndex += i;

            var entity = _context.User.Find(user.UserID);

            _context.Entry(entity).CurrentValues.SetValues(user);

            _context.SaveChanges();
        }
コード例 #4
0
        protected override void Seed(BookingsDbContext context)
        {
            var random            = new Random();
            var addressGenerator  = new AddressGenerator();
            var userNameGenerator = new UserNameGenerator();
            var passportGenerator = new PassportGenerator();

            for (int i = 0; i < 60; i++)
            {
                var fromDate = DateTime.Today.AddDays(random.Next(-2, 5));
                var toDate   = fromDate.AddDays(random.Next(1, 5));

                context.Bookings.Add(new Booking
                {
                    CustomerId   = "Cust-10" + i,
                    CustomerName = userNameGenerator.GetName(),
                    Address      = addressGenerator.GetAddress(),
                    From         = fromDate,
                    To           = toDate,
                    Passport     = passportGenerator.GetPassport(),
                    Amount       = random.Next(10, 40) * 100
                });
            }

            context.SaveChanges();

            base.Seed(context);
        }