Exemplo n.º 1
0
 /// <summary>
 /// Creates the specified type using the specified container
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="container">The container.</param>
 /// <returns></returns>
 /// <exception cref="System.InvalidOperationException">ServerMother only applies to </exception>
 public T Create <T>(IChillContainer container)
 {
     if (!Applies(typeof(T)))
     {
         throw new InvalidOperationException("ServerMother only applies to ");
     }
     return((T)(object)Create());
 }
Exemplo n.º 2
0
 /// <summary>
 /// Makes sure the container has been created.
 /// </summary>
 protected virtual void EnsureContainer()
 {
     if (container == null)
     {
         container = ChillContainerInitializer.BuildChillContainer(this);
     }
     EnsureContainerInitialized();
 }
Exemplo n.º 3
0
        public T Create <T>(IChillContainer container)
        {
            if (typeof(T) != typeof(Subject_built_By_Chill_AutoMother))
            {
                throw new InvalidOperationException("This builder can only build Subject_built_By_Chill_AutoMother");
            }

            return((T)(object)new Subject_built_By_Chill_AutoMother("I have been built by Chill"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// chill keeps a list of registered items in memory. This method adds a value to that list
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="container"></param>
        /// <param name="itemsToAdd"></param>
        /// <returns></returns>
        internal static IEnumerable <T> AddToList <T>(this IChillContainer container, params T[] itemsToAdd)
            where T : class
        {
            var list = GetList <T>(container);

            list.AddRange(itemsToAdd);


            return(list);
        }
Exemplo n.º 5
0
        /// <summary>
        /// chill keeps a list of registered items in memory. This method get's that list.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="container"></param>
        /// <returns></returns>
        internal static List <T> GetList <T>(this IChillContainer container) where T : class
        {
            var dictionary = container.Get <Dictionary <Type, object> >();


            if (dictionary == null || dictionary.Count == 0)
            {
                dictionary = new Dictionary <Type, object>();
            }

            object list;

            if (!dictionary.TryGetValue(typeof(T), out list))
            {
                list = new List <T>();
                dictionary.Add(typeof(T), list);
                container.Set(dictionary);
            }
            return((List <T>)list);
        }
Exemplo n.º 6
0
 public T Create <T>(IChillContainer container) where T : class
 {
     return(A.Fake <T>());
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ObjectMotherContainerDecorator" /> class.
 /// </summary>
 /// <param name="internalChillContainer">The internal chill container.</param>
 public ObjectMotherContainerDecorator(IChillContainer internalChillContainer)
 {
     this.internalChillContainer = internalChillContainer;
 }
 public ContainerResolverAdapter(IChillContainer container)
 {
     this.container = container;
 }
 /// <summary>
 /// Build the Chill Container. This container will be wrapped in a AutoMotherContainerDecorator.
 /// </summary>
 /// <returns></returns>
 public virtual IChillContainer BuildChillContainer(TestBase testBase)
 {
     return(container = Activator.CreateInstance <TContainerType>());
 }