public void FirstName_returns_a_randomly_chosen_first_name()
        {
            GetRandom.Random = new Random(1);
            var actual = GetRandom.FirstName();

            actual.ShouldBe("Bradley");
        }
        public void FirstName_true_returns_a_randomly_chosen_male_first_name()
        {
            GetRandom.Random = new Random(1);
            var actual = GetRandom.FirstName(true);

            actual.ShouldBe("Conner");
        }
        public void FirstName_false_returns_a_randomly_chosen_female_first_name()
        {
            GetRandom.Random = new Random(1);
            var actual = GetRandom.FirstName(false);

            actual.ShouldBe("Cassidy");
        }
        public void WHEN_creating_user_fails_SHOULD_not_attempt_to_merge_cart()
        {
            //Arrange
            var sut = _container.CreateInstance <MembershipViewService>();

            _container.GetMock <ICustomerRepository>()
            .Setup(p => p.CreateUserAsync(It.IsAny <CreateUserParam>()))
            .Throws(new ComposerException(GetRandom.String(3)));

            //Act and Assert
            Assert.ThrowsAsync <ComposerException>(() => sut.RegisterAsync(new CreateUserParam
            {
                Email            = GetRandom.Email(),
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = GetRandom.Email(),
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = GetRandom.String(32),
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32),
            }));

            _container.GetMock <ICartMergeProvider>().Verify(provider => provider.MergeCartAsync(It.IsAny <CartMergeParam>()), Times.Never);
        }
        public void WHEN_passing_empty_email_SHOULD_throw_ArgumentException(string email)
        {
            //Arrange
            var sut = _container.CreateInstance <MembershipViewService>();

            sut.Membership = _container.Get <IMembershipProxy>();
            var param = new CreateUserParam
            {
                Email            = email,
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = GetRandom.Email(),
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = GetRandom.String(32),
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32)
            };

            // Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => sut.RegisterAsync(param));

            //Assert
            exception.Message.Should().Contain("Email");
        }
        public async Task WHEN_passing_empty_PasswordAnswer_SHOULD_succeed(string passwordAnswer)
        {
            //Arrange
            var expectedCustomer   = MockCustomerFactory.CreateRandom();
            var customerRepository = _container.CreateInstance <CustomerRepository>();

            _container.GetMock <IOvertureClient>()
            .Setup(p => p.SendAsync(It.Is <CreateCustomerMembershipRequest>(param => string.IsNullOrWhiteSpace(param.PasswordAnswer))))
            .ReturnsAsync(expectedCustomer);

            //Act
            var result = await customerRepository.CreateUserAsync(new CreateUserParam
            {
                Email            = GetRandom.Email(),
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = GetRandom.Email(),
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = passwordAnswer,
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32)
            });

            //Assert
            result.Id.Should().Be(expectedCustomer.Id);
        }
        public async Task WHEN_passing_empty_username_SHOULD_fallback_to_email_as_username(string username)
        {
            //Arrange
            var customerRepository = _container.CreateInstance <CustomerRepository>();

            var expectedEmail = GetRandom.Email();

            _container.GetMock <IOvertureClient>()
            .Setup(r => r.SendAsync(It.Is <CreateCustomerMembershipRequest>(param => string.IsNullOrWhiteSpace(param.Username))))
            .ReturnsAsync(new Customer
            {
                Id            = GetRandom.Guid(),
                Email         = expectedEmail,
                Username      = expectedEmail,
                AccountStatus = AccountStatus.Active
            });

            //Act
            var result = await customerRepository.CreateUserAsync(new CreateUserParam
            {
                Email            = expectedEmail,
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = username,
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = GetRandom.String(32),
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32)
            });

            //Assert
            result.Email.Should().BeEquivalentTo(expectedEmail);
            result.Username.Should().BeEquivalentTo(expectedEmail);
        }
        public async Task WHEN_passing_empty_PasswordAnswer_SHOULD_succeed(string passwordAnswer)
        {
            //Arrange
            var expectedCustomer = MockCustomerFactory.CreateRandom();
            var sut = _container.CreateInstance <MembershipViewService>();

            sut.Membership = _container.Get <IMembershipProxy>();

            _container.GetMock <ICustomerRepository>()
            .Setup(p => p.CreateUserAsync(It.Is <CreateUserParam>(param => string.IsNullOrWhiteSpace(param.PasswordAnswer))))
            .ReturnsAsync(expectedCustomer);

            //Act
            var result = await sut.RegisterAsync(new CreateUserParam
            {
                Email            = GetRandom.Email(),
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = GetRandom.Email(),
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = passwordAnswer,
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32)
            });

            //Assert
            result.Status.Should().Be(MyAccountStatus.Success.ToString());
        }
        public async Task WHEN_passing_empty_username_SHOULD_fallback_to_email_as_username(string username)
        {
            //Arrange
            var sut = _container.CreateInstance <MembershipViewService>();

            sut.Membership = _container.Get <IMembershipProxy>();

            var expectedEmail = GetRandom.Email();

            _container.GetMock <ICustomerRepository>()
            .Setup(p => p.CreateUserAsync(It.Is <CreateUserParam>(param => string.IsNullOrWhiteSpace(param.Username))))
            .ReturnsAsync(new Customer
            {
                Email    = expectedEmail,
                Username = expectedEmail
            });

            //Act
            var result = await sut.RegisterAsync(new CreateUserParam
            {
                Email            = expectedEmail,
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = username,
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = GetRandom.String(32),
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = GetRandom.String(32)
            });

            //Assert
            result.Status.Should().Be(MyAccountStatus.Success.ToString());
            result.Username.Should().BeEquivalentTo(expectedEmail);
        }
示例#10
0
        public async Task Send_WhenWithMessage_ShouldBroadCastMessage()
        {
            // arrange
            Setup();

            var hostAddressValue = _hostAddress.Value;
//            var hostAddressValue = "http://localhost:5000";
            var coreDockerSockets = new CoreDockerSockets(hostAddressValue)
            {
                OverrideLogging = builder => builder.AddConsole()
            };
            var expected = "hi " + GetRandom.FirstName();

            // assert
            var list = new List <string>();
            await coreDockerSockets.Chat.OnReceived(s => list.Add(s));

            await coreDockerSockets.Chat.Send(expected);

            await coreDockerSockets.Chat.Send(expected);

            await coreDockerSockets.Chat.Send(expected);

            list.WaitFor(x => x.Count > 3);
            list.Should().HaveCount(3).And.Contain(expected);
        }
        public void CreateTokenTest()
        {
            PayUTokens.ApiKey      = base.apiKey;
            PayUTokens.ApiLogin    = base.apiLogin;
            PayUTokens.Language    = Language.en;
            PayUTokens.PaymentsUrl = base.paymentsUrl;

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            string nameOnCard = string.Format("{0} {1}",
                                              GetRandom.FirstName(), GetRandom.LastName());

            parameters.Add(PayUParameterName.PAYER_NAME, nameOnCard);
            parameters.Add(PayUParameterName.CREDIT_CARD_NUMBER, "4005580000029205");
            parameters.Add(PayUParameterName.CREDIT_CARD_EXPIRATION_DATE, "2015/12");
            parameters.Add(PayUParameterName.PAYMENT_METHOD, "VISA");
            parameters.Add(PayUParameterName.PAYER_ID, GetRandom.NumericString(6));

            TokenResponse response = PayUTokens.Instance.Create(parameters);

            Assert.IsNotNull(response);
            Assert.AreEqual(ResponseCode.SUCCESS, response.ResponseCode);
            Assert.IsNotNull(response.CreditCardToken.TokenId);
            Assert.AreEqual(36, response.CreditCardToken.TokenId.Length);
        }
示例#12
0
        private static T ValidData <T>(T value)
        {
            var project = value as Project;

            if (project != null)
            {
                project.Name = GetRandom.String(20);
            }

            var user = value as User;

            if (user != null)
            {
                user.Name           = GetRandom.FirstName() + " " + GetRandom.LastName();
                user.Email          = (Regex.Replace(user.Name.ToLower(), "[^a-z]", "") + GetRandom.NumericString(3) + "@nomailmail.com").ToLower();
                user.HashedPassword = GetRandom.String(20);
                user.Roles.Add("Guest");
            }

            var userGrant = value as UserGrant;

            if (userGrant != null)
            {
                userGrant.User = Builder <User> .CreateNew().Build().ToReference();
            }
            return(value);
        }
        public void DoAuthorizationTest()
        {
            PayUPayments.ApiKey      = base.apiKey;
            PayUPayments.ApiLogin    = base.apiLogin;
            PayUPayments.Language    = Language.en;
            PayUPayments.PaymentsUrl = base.paymentsUrl;
            PayUPayments.MerchantId  = 1;

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            string nameOnCard = string.Format("{0} {1}",
                                              GetRandom.FirstName(), GetRandom.LastName());

            parameters.Add(PayUParameterName.PAYER_NAME, nameOnCard);

            parameters.Add(PayUParameterName.PAYER_CITY, GetRandom.UK.County());
            parameters.Add(PayUParameterName.PAYER_STREET, GetRandom.NumericString(4));
            parameters.Add(PayUParameterName.INSTALLMENTS_NUMBER, GetRandom.Short(1, 9).ToString()); // revisar validacion
            parameters.Add(PayUParameterName.COUNTRY, PaymentCountry.PA.ToString());                 //  GetRandom.Enumeration<PaymentCountry>();

            int accountId = 8;                                                                       // Panamá

            parameters.Add(PayUParameterName.ACCOUNT_ID, accountId.ToString());
            parameters.Add(PayUParameterName.CURRENCY, Currency.USD.ToString());

            string orderReferenceCode = GetRandom.String(6, true, null);

            parameters.Add(PayUParameterName.REFERENCE_CODE, orderReferenceCode);
            parameters.Add(PayUParameterName.DESCRIPTION, GetRandom.Phrase(20));

            // Cookie of the current user session
            parameters.Add(PayUParameterName.COOKIE, "cookie_" + DateTime.Now.Ticks);

            decimal transactionValue = new decimal(10000);

            parameters.Add(PayUParameterName.VALUE, transactionValue.ToString("#.##"));

            decimal transactionTaxValue = new decimal(16);

            parameters.Add(PayUParameterName.TAX_VALUE, transactionTaxValue.ToString("#.##"));

            decimal transactionReturnBase = new decimal(100);

            parameters.Add(PayUParameterName.TAX_RETURN_BASE, transactionReturnBase.ToString("#.##"));

            parameters.Add(PayUParameterName.CREDIT_CARD_NUMBER, "4005580000029205");
            parameters.Add(PayUParameterName.CREDIT_CARD_EXPIRATION_DATE, "2015/12");
            parameters.Add(PayUParameterName.CREDIT_CARD_SECURITY_CODE, "495");
            parameters.Add(PayUParameterName.PAYMENT_METHOD, "VISA");

            PaymentResponse paymentResponse = PayUPayments.Instance.DoAuthorization(parameters);

            Assert.IsNotNull(paymentResponse);
            Assert.AreEqual(ResponseCode.SUCCESS, paymentResponse.ResponseCode);
            Assert.AreEqual(36, paymentResponse.TransactionResponse.TransactionId.Length); // :) 36 UUID length
            Assert.AreEqual(TransactionState.APPROVED, paymentResponse.TransactionResponse.State);
            Assert.Greater(paymentResponse.TransactionResponse.OrderId, 1);
            Assert.AreEqual(TransactionResponseCode.APPROVED, paymentResponse.TransactionResponse.ResponseCode);
        }
示例#14
0
        protected override void When()
        {
            base.When();

            _model.FirstName  = GetRandom.FirstName();
            _model.MiddleName = GetRandom.FirstName();
            _model.LastName   = GetRandom.LastName();
            _model.UserName   = GetRandom.String(1, 50);

            SUT.SaveChangesAsync(AdminUserId).Wait();
        }
示例#15
0
 private static Comment CreateAFakeComment(DateTime questionCreatedOn)
 {
     return(Builder <Comment>
            .CreateNew()
            .With(x => x.Content = GetRandom.Phrase(GetRandom.PositiveInt(20)))
            .And(x => x.CreatedOn = GetRandom.DateTime(questionCreatedOn.AddMinutes(5), DateTime.UtcNow))
            .And(x => x.CreatedByUserId = string.Format("{0}.{1}", GetRandom.FirstName(), GetRandom.LastName()))
            // If Rand number between 1-10 <= 5, then votes = another rand numb between 1-5. else 0.
            .And(x => x.UpVoteCount = (GetRandom.PositiveInt(10) <= 6 ? GetRandom.PositiveInt(5) : 0))
            .Build());
 }
示例#16
0
 private static User CreateAFakeUser()
 {
     return(Builder <User>
            .CreateNew()
            .With(x => x.Id = null)
            .With(x => x.FullName = string.Format("{0} {1}", GetRandom.FirstName(), GetRandom.LastName()))
            .And(x => x.DisplayName = x.FullName.Replace(' ', '.'))
            .And(x => x.Email = GetRandom.Email())
            .And(x => x.CreatedOn = GetRandom.DateTime(DateTime.UtcNow.AddMonths(-1), DateTime.UtcNow))
            .And(x => x.Reputation = GetRandom.PositiveInt(50000))
            .And(x => x.IsActive = GetRandom.Boolean())
            .Build());
 }
 public static User Simple()
 {
     return(new User
     {
         Address = AddressBuilder.Simple().Build(),
         FirstName = GetRandom.FirstName(),
         LastName = GetRandom.LastName(),
         MiddleName = GetRandom.FirstName(),
         PasswordHash = GetRandom.String(),
         PhoneNumber = GetRandom.String(10, 10),
         UserName = GetRandom.String(1, 20)
     });
 }
        public static Agent CreateAFakeAgent()
        {
            var communications = new List <Communication>
            {
                FakeCommunication.CreateAFakeCommunication()
            };

            if (GetRandom.Int(1, 5) == 1)
            {
                communications.Add(FakeCommunication.CreateAFakeCommunication(CommunicationType.Email));
            }

            return(Builder <Agent> .CreateNew()
                   .With(x => x.Name, $"{GetRandom.FirstName()} {GetRandom.LastName()}")
                   .With(x => x.Communications, communications)
                   .Build());
        }
示例#19
0
        private static void PushDataToDocumentStore(ShardedDocumentStore docStore)
        {
            var users = new List <User>();

            for (var i = 0; i < 30; i++)
            {
                using (var session = docStore.OpenSession())
                {
                    var user =
                        Builder <User> .CreateNew()
                        .With(x => x.Id       = null)
                        .With(x => x.Username = GetRandom.FirstName() + "." + GetRandom.LastName())
                        .Build();

                    session.Store(user);
                    Console.WriteLine("Storing {0}...", user.Id);
                    session.SaveChanges();

                    users.Add(user); // storing user objects so we an add orders for them
                }
            }

            for (var i = 0; i < 10; i++)
            {
                using (var session = docStore.OpenSession())
                {
                    var order = Builder <Order> .CreateNew()
                                .With(x => x.UserId     = users[GetRandom.Int(0, users.Count - 1)].Id)
                                .With(x => x.Id         = null)
                                .With(x => x.TotalPrice = GetRandom.PositiveDouble())
                                .Build();

                    session.Store(order);
                    var color = Console.ForegroundColor;

                    if (!order.UserId.StartsWith(order.Id.Substring(0, 7)))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                    }

                    Console.WriteLine("Storing {0} for user {1}...", order.Id, order.UserId);
                    Console.ForegroundColor = color;
                    session.SaveChanges();
                }
            }
        }
示例#20
0
        private void CreatePersons(EfRepository repository)
        {
            var twitterUris = new List <string> {
                "https://twitter.com/1van1111", "https://twitter.com/mnzadornov"
            };
            var facebookUris = new List <string> {
                "http://www.facebook.com/ivan.zaporozhchenko", "http://www.facebook.com/dmitriy.stranger.7"
            };
            var linkedInUris = new List <string> {
                "http://ua.linkedin.com/in/titarenko", "http://ua.linkedin.com/in/olvia"
            };
            var countries = new List <string> {
                "Ukraine", "Poland", "Russia", "England", "USA", "Slovakia", "Finland"
            };

            var randomTwitterUri  = new RandomItemPicker <string>(twitterUris, new RandomGenerator());
            var randomFacebookUri = new RandomItemPicker <string>(facebookUris, new RandomGenerator());
            var randomlinkedInUri = new RandomItemPicker <string>(linkedInUris, new RandomGenerator());
            var randomCountry     = new RandomItemPicker <string>(countries, new RandomGenerator());

            var persons = Builder <Person> .CreateListOfSize(15)
                          .All()
                          .With(x => x.FirstName    = GetRandom.FirstName())
                          .With(x => x.LastName     = GetRandom.LastName())
                          .With(x => x.Role         = PersonRole.Employee)
                          .With(x => x.Country      = randomCountry.Pick())
                          .With(x => x.Email        = x.FullName.Replace(" ", "") + "@example.com")
                          .With(x => x.Phone        = GetRandom.Usa.PhoneNumber())
                          .With(x => x.CreationDate = GetRandom.DateTime(January.The1st, DateTime.Now))
                          .With(x => x.Id           = 0)
                          .With(x => x.PhotoUri     = "")
                          .With(x => x.FacebookUri  = randomFacebookUri.Pick())
                          .With(x => x.LinkedInUri  = randomlinkedInUri.Pick())
                          .With(x => x.TwitterUri   = randomTwitterUri.Pick())
                          .TheFirst(10)
                          .With(x => x.Role = PersonRole.Client)
                          .Build();

            foreach (var person in persons)
            {
                repository.Save(person);
            }
        }
示例#21
0
        public async Task WHEN_param_ok_no_shipmentId_SHOULD_call_overture_with_AddPaymentRequest_and_SHOULD_return_ProcessedCart(bool includeBillingAddress)
        {
            //Arrange
            var sut            = _container.CreateInstance <CartRepository>();
            var billingAddress = includeBillingAddress
                ? new Address
            {
                City                = GetRandom.String(7),
                CountryCode         = GetRandom.UpperCaseString(2),
                RegionCode          = GetRandom.Usa.State(),
                Email               = GetRandom.Email(),
                FirstName           = GetRandom.FirstName(),
                LastName            = GetRandom.LastName(),
                IsPreferredBilling  = GetRandom.Boolean(),
                IsPreferredShipping = GetRandom.Boolean(),
                Line1               = GetRandom.String(25),
                PhoneNumber         = GetRandom.Usa.PhoneNumber(),
                PostalCode          = GetRandom.String(6)
            } : null;

            var param = new AddPaymentParam
            {
                Amount         = GetRandom.PositiveDecimal(1000.0m),
                CartName       = GetRandom.String(10),
                BillingAddress = billingAddress,
                CultureInfo    = CultureInfo.InvariantCulture,
                CustomerId     = GetRandom.Guid(),
                Scope          = GetRandom.String(10)
            };

            //Act
            var cart = await sut.AddPaymentAsync(param);

            //Assert
            cart.Should().NotBeNull();
            cart.Payments.Should().NotBeNullOrEmpty();

            var payment = cart.Payments.First();

            payment.BillingAddress.Should().Be(billingAddress);

            _container.Verify <IOvertureClient>(c => c.SendAsync(It.IsAny <AddPaymentRequest>()));
        }
示例#22
0
        public static async Task Main(string[] args)
        {
            Console.WriteLine("Starting bulk insert testing app.");

            var documentStore = new DocumentStore()
            {
                Urls     = new[] { "http://localhost:8080" },
                Database = "BulkInsertTest"
            }.Initialize();

            // Create a list of fake employees.
            var employees = Builder <Employee> .CreateListOfSize(1000 * 1000)
                            //var employees = Builder<Employee>.CreateListOfSize(100)
                            .All()
                            .With(x => x.FirstName, GetRandom.FirstName())
                            .And(x => x.LastName, GetRandom.LastName())
                            .Build();

            Console.WriteLine("Created all fake employees.");

            var batches = employees.Batch(10000);

            var stopwatch = Stopwatch.StartNew();

            try
            {
                foreach (var batch in batches)
                {
                    await BulkInsertEmployees(batch, documentStore);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }

            stopwatch.Stop();

            Console.WriteLine($"Inserted {employees.Count:N0} employee's in {stopwatch.Elapsed.TotalSeconds:N2} seconds.");

            Console.WriteLine("-- Press any key to quit.");
            Console.ReadKey();
        }
 /// <summary>
 /// Gets a random Customer
 /// </summary>
 /// <param name="status"></param>
 /// <param name="customerId"></param>
 /// <returns></returns>
 public static Customer CreateRandom(AccountStatus?status = null, Guid?customerId = null)
 {
     return(new Customer
     {
         AccountStatus = status ?? TestingExtensions.GetRandomEnum <AccountStatus>(),
         Id = customerId ?? GetRandom.Guid(),
         CellNumber = GetRandom.String(32),
         PropertyBag = new PropertyBag(),
         Addresses = new List <Address>(),
         AddressIds = new List <Guid>(),
         Created = GetRandom.DateTime(),
         Email = GetRandom.Email(),
         Username = GetRandom.Email(),
         FirstName = GetRandom.FirstName(),
         LastName = GetRandom.LastName(),
         PasswordQuestion = GetRandom.String(70),
         CustomerType = TestingExtensions.GetRandomEnum <CustomerType>(),
         LastModifiedBy = GetRandom.Email(),
         CreatedBy = GetRandom.Email(),
         LastModified = GetRandom.DateTime(),
         Language = TestingExtensions.GetRandomCulture().Name,
         FaxExtension = GetRandom.String(5),
         FaxNumber = GetRandom.String(32),
         IsRecurringBuyer = GetRandom.Boolean(),
         LastActivityDate = GetRandom.DateTime(),
         LastLoginDate = GetRandom.DateTime(),
         LastOrderCurrency = GetRandom.String(32),
         LastOrderDate = GetRandom.DateTime(),
         LastOrderItemsCount = GetRandom.PositiveInt(32),
         LastOrderNumber = GetRandom.String(32),
         LastOrderStatus = GetRandom.String(32),
         LastOrderTotal = GetRandom.PositiveInt(12094),
         LastPasswordChanged = GetRandom.DateTime(),
         MiddleName = GetRandom.LastName(),
         PhoneExtension = GetRandom.String(5),
         PhoneNumber = GetRandom.String(20),
         PhoneExtensionWork = GetRandom.String(5),
         PhoneNumberWork = GetRandom.String(20),
         PreferredStoreId = GetRandom.Guid()
     });
 }
示例#24
0
        public async Task <ActionResult> AddRandom()
        {
            var items = Builder <Contact> .CreateListOfSize(5)
                        .All().With(x => x.Id    = Guid.NewGuid().ToString())
                        .With(x => x.Firstname   = GetRandom.FirstName())
                        .With(x => x.Lastname    = GetRandom.LastName())
                        .With(x => x.Description = GetRandom.Phrase(10))
                        .With(x => x.BirthDate   = GetRandom.DateTime())
                        .With(x => x.Address     = Builder <Address> .CreateNew()
                                                   .With(y => y.Country     = GetRandom.Usa.State())
                                                   .With(y => y.AddressLine = GetRandom.Phrase(20))
                                                   .With(y => y.ZipCode     = GetRandom.Int(0, 99999).ToString())
                                                   .Build())
                        .Build();

            foreach (var item in items)
            {
                await this.documentDbRepository.CreateItemAsync(item);
            }

            return(this.RedirectToAction("Index"));
        }
        public void WHEN_passing_empty_Scope_SHOULD_throw_ArgumentException(string scope)
        {
            //Arrange
            var customerRepository = _container.CreateInstance <CustomerRepository>();
            var param = new CreateUserParam
            {
                Email            = GetRandom.Email(),
                FirstName        = GetRandom.FirstName(),
                LastName         = GetRandom.LastName(),
                Username         = GetRandom.Email(),
                Password         = GetRandom.String(32),
                PasswordQuestion = GetRandom.String(32),
                PasswordAnswer   = GetRandom.String(32),
                CultureInfo      = TestingExtensions.GetRandomCulture(),
                Scope            = scope
            };

            // Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => customerRepository.CreateUserAsync(param));

            //Assert
            exception.Message.Should().Contain("Scope");
        }
        public static Order CreateAFakeOrder()
        {
            var fakeOrder = Builder <Order>
                            .CreateNew()
                            .With(x => x.CustomerName = string.Concat(GetRandom.FirstName(), " ", GetRandom.LastName()))
                            .With(x => x.CreatedAt    = DateTimeOffset.UtcNow)
                            .And(x => x.IpAddress     = GetRandom.IpAddress()) // TODO map IpAddress to a geo-location
                            .Build();

            fakeOrder.OrderLines = new List <OrderLine>();
            for (var i = 0; i < GetRandom.Int(1, 20); i++)
            {
                var productId = GetRandom.Int(1, 30); // Demo for 30 products so we get nicer reporting screens
                fakeOrder.OrderLines.Add(new OrderLine
                {
                    ProductId   = "products/" + productId,
                    ProductName = ProductsCatalogue.GetOrAdd(productId, _ => GetRandom.Phrase(15)),
                    Quantity    = GetRandom.Int(1, 5),
                    UnitPrice   = GetRandom.Int(5, 500) + (GetRandom.Int(0, 99) / 100), // prettier prices
                });
            }

            return(fakeOrder);
        }
示例#27
0
 /// <summary>
 /// Gets a random Address
 /// </summary>
 /// <returns></returns>
 public static Address CreateRandom()
 {
     return(new Address
     {
         Id = GetRandom.Guid(),
         AddressName = GetRandom.String(32),
         City = GetRandom.String(32),
         CountryCode = GetRandom.String(2),
         Email = GetRandom.Email(),
         FirstName = GetRandom.FirstName(),
         LastName = GetRandom.LastName(),
         IsPreferredBilling = GetRandom.Boolean(),
         IsPreferredShipping = GetRandom.Boolean(),
         Latitude = GetRandom.Double(),
         Longitude = GetRandom.Double(),
         Line1 = GetRandom.String(40),
         Line2 = GetRandom.String(40),
         Notes = GetRandom.String(1029),
         PhoneExtension = GetRandom.String(3),
         PhoneNumber = GetRandom.String(12),
         PostalCode = GetRandom.String(7),
         RegionCode = GetRandom.String(4)
     });
 }