Esempio n. 1
0
        public static IPersistentState <T> AddPersistentState <T>(
            this TestKitSilo silo,
            IStorage <T> storage,
            string stateName,
            string storageName = default,
            T state            = default)
            where T : new()
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            if (string.IsNullOrWhiteSpace(stateName))
            {
                throw new ArgumentException("A state name must be provided", nameof(stateName));
            }

            if (storage is null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            silo.StorageManager.AddStorage(storage, stateName);
            return(silo.StorageManager.stateAttributeFactoryMapper.AddPersistentState(storage, stateName, storageName, state));
        }
        public static Mock <T> AddServiceProbe <T>(this TestKitSilo silo) where T : class
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.ServiceProvider.AddServiceProbe <T>());
        }
Esempio n. 3
0
        public static TestStorageStats StorageStats(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.StorageManager.GetStorageStats());
        }
Esempio n. 4
0
        public static Task FireTimerAsync(this TestKitSilo silo, int index)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.TimerRegistry.FireAsync(index));
        }
Esempio n. 5
0
        public static Task FireAllTimersAsync(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.TimerRegistry.FireAllAsync());
        }
Esempio n. 6
0
        public static void FireAllTimers(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            silo.TimerRegistry.FireAll();
        }
Esempio n. 7
0
        public static void FireTimer(this TestKitSilo silo, int index)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            silo.TimerRegistry.Fire(index);
        }
Esempio n. 8
0
        public static TState State <TState>(this TestKitSilo silo) where TState : class, new()
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.StorageManager.GetStorage <TState>().State);
        }
        public static T AddService <T>(this TestKitSilo silo, T instance) where T : class
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.ServiceProvider.AddService(instance));
        }
Esempio n. 10
0
        public static Task FireAllReminders(this TestKitSilo silo, TickStatus tickStatus = default)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.ReminderRegistry.FireAllReminders(tickStatus));
        }
Esempio n. 11
0
        public static Mock <T> AddProbe <T>(this TestKitSilo silo, long id, string classPrefix = null)
            where T : class, IGrainWithIntegerKey
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.GrainFactory.AddProbe <T>(new TestGrainIdentity(id), classPrefix));
        }
Esempio n. 12
0
        public static void AddProbe <T>(this TestKitSilo silo, Func <IGrainIdentity, IMock <T> > factory)
            where T : class, IGrain
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            silo.GrainFactory.AddProbe(factory);
        }
Esempio n. 13
0
        public static Mock <T> AddProbe <T>(this TestKitSilo silo, Guid id, string keyExtension, string classPrefix = null)
            where T : class, IGrainWithGuidCompoundKey
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.GrainFactory.AddProbe <T>(new TestGrainIdentity(id, keyExtension), classPrefix));
        }
Esempio n. 14
0
        public static Task FireReminder(this TestKitSilo silo, string reminderName, TickStatus tickStatus = default)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            if (reminderName == null)
            {
                throw new ArgumentNullException(nameof(reminderName));
            }

            return(silo.ReminderRegistry.FireReminder(reminderName, tickStatus));
        }
Esempio n. 15
0
        public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id, string streamNamespace, string providerName)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            if (providerName == null)
            {
                throw new ArgumentNullException(nameof(providerName));
            }

            return(silo.StreamProviderManager.AddStreamProbe <T>(id, streamNamespace, providerName));
        }
Esempio n. 16
0
        public static IStorage <T> AddGrainState <TGrain, T>(
            this TestKitSilo silo,
            T state = default)
            where TGrain : Grain <T>
            where T : new()
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            var storage = silo.StorageManager.GetGrainStorage <TGrain, T>();

            storage.State = state ?? new T();
            return(storage);
        }
Esempio n. 17
0
        public static IPersistentState <T> AddPersistentState <T>(
            this TestKitSilo silo,
            string stateName,
            string storageName = default,
            T state            = default)
            where T : new()
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            if (string.IsNullOrWhiteSpace(stateName))
            {
                throw new ArgumentException("A state name must be provided", nameof(stateName));
            }

            var storage = silo.StorageManager.GetStorage <T>(stateName);

            return(AddPersistentState(silo, storage, stateName, storageName, state));
        }
Esempio n. 18
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id, string streamNamespace) =>
 AddStreamProbe <T>(silo, id, streamNamespace, "Default");
Esempio n. 19
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id) =>
 AddStreamProbe <T>(silo, id, typeof(T).Name);
 public static Mock <T> AddServiceProbe <T>(this TestKitSilo silo, Mock <T> mock) where T : class
 => silo.ServiceProvider.AddServiceProbe(mock);
 public static T AddService <T>(this TestKitSilo silo, T instance) where T : class
 => silo.ServiceProvider.AddService(instance);
Esempio n. 22
0
 public static Mock <T> AddProbe <T>(this TestKitSilo silo, Guid id, string keyExtension, string classPrefix = null) where T : class, IGrainWithGuidCompoundKey
 => silo.GrainFactory.AddProbe <T>(new TestGrainIdentity(id, keyExtension), classPrefix);
Esempio n. 23
0
 public static void AddProbe <T>(this TestKitSilo silo, Func <IGrainIdentity, IMock <T> > factory) where T : class, IGrain
 => silo.GrainFactory.AddProbe <T>(factory);
Esempio n. 24
0
 public static TState State <TGrain, TState>(this TestKitSilo silo)
     where TGrain : Grain <TState>
     where TState : class, new()
 => silo.StorageManager.GetGrainStorage <TGrain, TState>().State;
Esempio n. 25
0
 public static TestStorageStats StorageStats(this TestKitSilo silo) =>
 silo.StorageManager.GetStorageStats();
 public static Task FireAllReminders(this TestKitSilo silo, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireAllReminders(tickStatus);
Esempio n. 27
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo) =>
 AddStreamProbe <T>(silo, Guid.Empty);
Esempio n. 28
0
 public static Mock <T> AddProbe <T>(this TestKitSilo silo, long id, string classPrefix = null) where T : class, IGrainWithIntegerKey
 => silo.GrainFactory.AddProbe <T>(new TestGrainIdentity(id), classPrefix);
 public static Task FireReminder(this TestKitSilo silo, string reminderName, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireReminder(reminderName, tickStatus);
Esempio n. 30
0
 public static TState State <TState>(this TestKitSilo silo) where TState : class, new() =>
 silo.StorageManager.GetStorage <TState>().State;