コード例 #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));
        }
コード例 #2
0
        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>());
        }
コード例 #3
0
        public static TestStorageStats StorageStats(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

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

            return(silo.TimerRegistry.FireAsync(index));
        }
コード例 #5
0
        public static Task FireAllTimersAsync(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            return(silo.TimerRegistry.FireAllAsync());
        }
コード例 #6
0
        public static void FireAllTimers(this TestKitSilo silo)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            silo.TimerRegistry.FireAll();
        }
コード例 #7
0
        public static void FireTimer(this TestKitSilo silo, int index)
        {
            if (silo == null)
            {
                throw new ArgumentNullException(nameof(silo));
            }

            silo.TimerRegistry.Fire(index);
        }
コード例 #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);
        }
コード例 #9
0
        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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #18
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id, string streamNamespace) =>
 AddStreamProbe <T>(silo, id, streamNamespace, "Default");
コード例 #19
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo, Guid id) =>
 AddStreamProbe <T>(silo, id, typeof(T).Name);
コード例 #20
0
 public static Mock <T> AddServiceProbe <T>(this TestKitSilo silo, Mock <T> mock) where T : class
 => silo.ServiceProvider.AddServiceProbe(mock);
コード例 #21
0
 public static T AddService <T>(this TestKitSilo silo, T instance) where T : class
 => silo.ServiceProvider.AddService(instance);
コード例 #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);
コード例 #23
0
 public static void AddProbe <T>(this TestKitSilo silo, Func <IGrainIdentity, IMock <T> > factory) where T : class, IGrain
 => silo.GrainFactory.AddProbe <T>(factory);
コード例 #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;
コード例 #25
0
 public static TestStorageStats StorageStats(this TestKitSilo silo) =>
 silo.StorageManager.GetStorageStats();
コード例 #26
0
 public static Task FireAllReminders(this TestKitSilo silo, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireAllReminders(tickStatus);
コード例 #27
0
 public static TestStream <T> AddStreamProbe <T>(this TestKitSilo silo) =>
 AddStreamProbe <T>(silo, Guid.Empty);
コード例 #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);
コード例 #29
0
 public static Task FireReminder(this TestKitSilo silo, string reminderName, TickStatus tickStatus = new TickStatus())
 => silo.ReminderRegistry.FireReminder(reminderName, tickStatus);
コード例 #30
0
 public static TState State <TState>(this TestKitSilo silo) where TState : class, new() =>
 silo.StorageManager.GetStorage <TState>().State;