public Task GivenIHaveCreatedAndStoredNotificationsWithTimestampsAtSecondIntervalsForTheUserWithId(int notificationCount, int interval, string userId) { IUserNotificationStore store = this.serviceProvider.GetRequiredService <IUserNotificationStore>(); IPropertyBagFactory propertyBagFactory = this.serviceProvider.GetRequiredService <IPropertyBagFactory>(); DateTimeOffset timestamp = DateTimeOffset.UtcNow; var offset = TimeSpan.FromSeconds(interval); var tasks = new List <Task>(); var propertiesDictionary = new Dictionary <string, object> { { "prop1", "val1" }, { "prop2", 2 }, { "prop3", DateTime.Now }, }; IPropertyBag properties = propertyBagFactory.Create(propertiesDictionary); for (int i = 0; i < notificationCount; i++) { string[] correlationIds = Enumerable.Range(0, 3).Select(_ => Guid.NewGuid().ToString()).ToArray(); var metadata = new UserNotificationMetadata(correlationIds, null); tasks.Add(store.StoreAsync(new UserNotification(null, "marain.usernotifications.test", userId, timestamp, properties, metadata))); timestamp -= offset; } return(Task.WhenAll(tasks)); }
/// <summary> /// Creates a property bag from a callback that produces a collection of key pair values. /// </summary> /// <param name="propertyBagFactory">The property bag factory.</param> /// <param name="builder">A function that builds the property collection.</param> /// <returns>A new property bag.</returns> /// <remarks> /// <para> /// This supports property builders designed to be chained together, e.g.: /// </para> /// <code><![CDATA[ /// IPropertyBag childProperties = this.propertyBagFactory.Create(start => /// start.AddBlobStorageConfiguration(ContainerDefinition, tenancyStorageConfiguration)); /// ]]></code> /// <para> /// It calls <see cref="IPropertyBagFactory.Create(IEnumerable{KeyValuePair{string, object}})"/> /// with the resulting properties. /// </para> /// </remarks> public static IPropertyBag Create( this IPropertyBagFactory propertyBagFactory, Func <IEnumerable <KeyValuePair <string, object> >, IEnumerable <KeyValuePair <string, object> > > builder) { IEnumerable <KeyValuePair <string, object> > values = builder(PropertyBagValues.Empty); return(propertyBagFactory.Create(values)); }
public async Task GivenIHaveCreatedAndStoredNotificationsInTheCurrentTransientTenantWithTimestampsAtSecondIntervalsForTheUserWithId(int notificationCount, int interval, string userId) { ITenantedUserNotificationStoreFactory storeFactory = this.serviceProvider.GetRequiredService <ITenantedUserNotificationStoreFactory>(); IUserNotificationStore store = await storeFactory.GetUserNotificationStoreForTenantAsync(this.featureContext.GetTransientTenant()).ConfigureAwait(false); IPropertyBagFactory propertyBagFactory = this.serviceProvider.GetRequiredService <IPropertyBagFactory>(); var offset = TimeSpan.FromSeconds(interval); DateTimeOffset timestamp = DateTimeOffset.UtcNow - offset; var tasks = new List <Task <UserNotification> >(); var propertiesDictionary = new Dictionary <string, object> { { "prop1", "val1" }, { "prop2", 2 }, { "prop3", DateTime.Now }, }; IPropertyBag properties = propertyBagFactory.Create(propertiesDictionary); for (int i = 0; i < notificationCount; i++) { string[] correlationIds = Enumerable.Range(0, 3).Select(_ => Guid.NewGuid().ToString()).ToArray(); var metadata = new UserNotificationMetadata(correlationIds, null); tasks.Add(store.StoreAsync(new UserNotification(null, "marain.usernotifications.test", userId, timestamp, properties, metadata))); timestamp -= offset; } UserNotification[] newlyCreatedNotifications = await Task.WhenAll(tasks).ConfigureAwait(false); // Store the notifications in session state if (!this.scenarioContext.TryGetValue(CreatedNotificationsKey, out List <UserNotification> createdNotifications)) { createdNotifications = new List <UserNotification>(); this.scenarioContext.Set(createdNotifications, CreatedNotificationsKey); } createdNotifications.AddRange(newlyCreatedNotifications); }
public RedactedRootTenant(IPropertyBagFactory propertyBagFactory) { this.Properties = propertyBagFactory.Create(PropertyBagValues.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="RootTenant"/> class. /// </summary> /// <param name="propertyBagFactory">Enables property bag creation and update.</param> public RootTenant(IPropertyBagFactory propertyBagFactory) : base(RootTenantId, RootTenantName, propertyBagFactory.Create(PropertyBagValues.Empty)) { this.propertyBagFactory = propertyBagFactory; }