Exemplo 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>());
        }
Exemplo n.º 3
0
        public static TestStorageStats StorageStats(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.StorageManager.GetStorageStats());
        }
Exemplo 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));
        }
Exemplo n.º 5
0
        public static Task FireAllTimersAsync(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

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

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

            silo.TimerRegistry.Fire(index);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo n.º 18
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id, string streamNamespace) =>
 AddStreamProbe <T>(silo, id, streamNamespace, "Default");
Exemplo 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);
Exemplo 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);
Exemplo 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);
Exemplo 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;
Exemplo n.º 25
0
 public static TestStorageStats StorageStats(this TestKitSilo silo) =>
 silo.StorageManager.GetStorageStats();
Exemplo n.º 26
0
 public static Task FireAllReminders(this TestKitSilo silo, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireAllReminders(tickStatus);
Exemplo n.º 27
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo) =>
 AddStreamProbe <T>(silo, Guid.Empty);
Exemplo 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);
Exemplo n.º 29
0
 public static Task FireReminder(this TestKitSilo silo, string reminderName, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireReminder(reminderName, tickStatus);
Exemplo n.º 30
0
 public static TState State <TState>(this TestKitSilo silo) where TState : class, new() =>
 silo.StorageManager.GetStorage <TState>().State;