public TransactionRepository() { _transactions = new List <Transaction>(); //var transaction = new Transaction //{ // TransactionId = 4, // CreatedDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-01)), // CurrencyCode = "en-GB", // Description = "Telsa", // TransactionAmount = 275000, // TransactionDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-1)), // Merchant = "Telsa", // ModifiedDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-01)) //}; _transactions = Builder <Transaction> .CreateListOfSize(50) .All() .With(x => x.TransactionId = GetRandom.Long(_transactions.Count(), 10000)) .With(x => x.CreatedDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-01))) .With(x => x.CurrencyCode = "en-GB") .With(x => x.Description = "Lamborghini") .With(x => x.TransactionAmount = 275000) .With(x => x.TransactionDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-1))) .With(x => x.Merchant = "Lamborghini") .With(x => x.ModifiedDate = GetRandom.DateTimeFrom(DateTime.Now.AddMonths(-01))) .Build(); }
public static Mock <IFulfillmentMethodRepository> MockFulfillmentRepoWithRandomMethods() { Guid shipmentId = GetRandom.Guid(); var fulfillmentRepoMock = new Mock <IFulfillmentMethodRepository>(); fulfillmentRepoMock.Setup(m => m.GetCalculatedFulfillmentMethods(It.IsNotNull <GetShippingMethodsParam>())) .ReturnsAsync(new List <FulfillmentMethod> { new FulfillmentMethod() { Id = GetRandom.Guid(), Cost = GetRandom.Double(0, 30.0), DisplayName = new LocalizedString(), ExpectedDeliveryDate = GetRandom.DateTimeFrom(DateTime.Now), FulfillmentMethodType = FulfillmentMethodType.Shipping, Name = GetRandom.String(12), ShipmentId = shipmentId, ShippingProviderId = GetRandom.Guid(), TaxCategory = GetRandom.String(12), PropertyBag = new PropertyBag() }, new FulfillmentMethod() { Id = GetRandom.Guid(), Cost = GetRandom.Double(0, 30.0), DisplayName = new LocalizedString(), ExpectedDeliveryDate = GetRandom.DateTimeFrom(DateTime.Now), FulfillmentMethodType = FulfillmentMethodType.Shipping, Name = GetRandom.String(12), ShipmentId = shipmentId, ShippingProviderId = GetRandom.Guid(), TaxCategory = GetRandom.String(12), PropertyBag = new PropertyBag() }, new FulfillmentMethod() { Id = GetRandom.Guid(), Cost = GetRandom.Double(0, 30.0), DisplayName = new LocalizedString(), ExpectedDeliveryDate = GetRandom.DateTimeFrom(DateTime.Now), FulfillmentMethodType = FulfillmentMethodType.Shipping, Name = GetRandom.String(12), ShipmentId = shipmentId, ShippingProviderId = GetRandom.Guid(), TaxCategory = GetRandom.String(12), PropertyBag = new PropertyBag() } }); return(fulfillmentRepoMock); }
public static T CreateAFakeListing <T>(string id = null, StatusType statusType = StatusType.Unknown) where T : Listing, new() { // NBuilder fails to return the last enum type, here :( // var statusType = GetRandom.Enumeration<StatusType>(); var values = EnumHelper.GetValues(typeof(StatusType)); var randomIndex = _random.Next(0, values.Length); if (statusType == StatusType.Unknown) { statusType = (StatusType)values.GetValue(randomIndex); if (statusType == StatusType.Unknown) { statusType = StatusType.Available; } } var createdOn = GetRandom.DateTime(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow.AddDays(-1)); createdOn = DateTime.SpecifyKind(createdOn, DateTimeKind.Utc); var updatedOn = GetRandom.DateTimeFrom(DateTime.UtcNow.AddDays(-1)); updatedOn = DateTime.SpecifyKind(updatedOn, DateTimeKind.Utc); // Yep, copied from FakeCommonListingHelpers because that is method is (correctly) internal :/ var listing = Builder <T> .CreateNew() .With(x => x.Id, id ?? $"listing-{GetRandom.Int()}") .With(x => x.AgencyId, $"Agency-{GetRandom.String(6)}") .With(x => x.StatusType, statusType) // NOTE: SourceStatus is defined AFTER this instance is created. .With(x => x.Address, FakeAddress.CreateAFakeAddress()) .With(x => x.Agents, FakeAgent.CreateFakeAgents()) .With(x => x.LandDetails, CreateLandDetails()) .With(x => x.Features, CreateFeatures()) .With(x => x.CreatedOn, createdOn) .With(x => x.UpdatedOn, updatedOn) .With(x => x.Images, CreateMedia(GetRandom.Int(1, 21))) .With(x => x.FloorPlans, CreateMedia(GetRandom.Int(0, 3))) .With(x => x.Documents, CreateMedia(GetRandom.Int(0, 4))) .With(x => x.Inspections, CreateInspections(GetRandom.Int(0, 4))) .With(x => x.Videos, CreateMedia(GetRandom.Int(0, 3), "application/octet-stream")) .Do(x => { if (x is ResidentialListing residentialListing) { // Skip first enumeration -> Unknown. var index = GetRandom.Int(1, Enum.GetValues(typeof(PropertyType)).Length); residentialListing.PropertyType = (PropertyType)Enum.GetValues(typeof(PropertyType)).GetValue(index); residentialListing.AuctionOn = CreateDateTimeAsUtcKind(100); residentialListing.BuildingDetails = CreateBuildingDetails(); residentialListing.Pricing = CreateSalePricing(residentialListing.StatusType); } else if (x is RentalListing rentalListing) { var index = GetRandom.Int(1, Enum.GetValues(typeof(PropertyType)).Length); rentalListing.PropertyType = (PropertyType)Enum.GetValues(typeof(PropertyType)).GetValue(index); rentalListing.AvailableOn = CreateDateTimeAsUtcKind(1000); rentalListing.BuildingDetails = CreateBuildingDetails(); rentalListing.Pricing = CreateRentalPricing(rentalListing.StatusType); } else if (x is LandListing landListing) { var index = GetRandom.Int(1, Enum.GetValues(typeof(CategoryType)).Length); landListing.CategoryType = (CategoryType)Enum.GetValues(typeof(CategoryType)).GetValue(index); landListing.AuctionOn = CreateDateTimeAsUtcKind(100); landListing.Estate = Builder <LandEstate> .CreateNew().Build(); landListing.Pricing = CreateSalePricing(landListing.StatusType); } else if (x is RuralListing ruralListing) { var index = GetRandom.Int(1, Enum.GetValues(typeof(Core.Rural.CategoryType)).Length); ruralListing.CategoryType = (Core.Rural.CategoryType)Enum.GetValues(typeof(Core.Rural.CategoryType)).GetValue(index); ruralListing.AuctionOn = CreateDateTimeAsUtcKind(100); ruralListing.Pricing = CreateSalePricing(ruralListing.StatusType); ruralListing.RuralFeatures = Builder <RuralFeatures> .CreateNew().Build(); ruralListing.BuildingDetails = CreateBuildingDetails(); } }).Build(); FakeCommonListingHelpers.SetSourceStatus(listing); return(listing); }