Example #1
0
        /// <summary>
        /// Instantiates a new WocketRepository.
        /// </summary>
        public WocketRepository()
        {
            // ObjectStores are created by the factory and are singleton per type.
            // IE, there will only ever be one Wocket ObjectStore.
            var factory = new ObjectStoreFactory();
            _objectStore = factory.CreateObjectStore<Wocket>();

            // As an alternate, you could make an IoC container responsible for
            // instantiating the ObjectFactory and only use the Dependency-Injection
            // constructor below.
        }
        public void CreateObjectStoreT_WithDifferentInstance_ReturnsSameObjectStore()
        {
            // Arrange
            var objectStoreFactory2 = new ObjectStoreFactory();

            // Act
            var objectStore1 = _objectStoreFactory.CreateObjectStore<SimpleTestObject>();
            var objectStore2 = objectStoreFactory2.CreateObjectStore<SimpleTestObject>();

            // Assert
            Assert.AreSame(objectStore1, objectStore2);
        }
Example #3
0
        /// <summary>
        /// Generates Sample Wockets into WocketDb.
        /// </summary>
        public static void GenerateWockets()
        {
            var factory = new ObjectStoreFactory();
            var wocketStore = factory.CreateObjectStore<Wocket>();

            for (int i = 1; i <= 10; i++)
            {
                wocketStore.Insert(new Wocket {
                    Id = wocketStore.NextId,
                    Name = String.Format("Wocket {0}", i)
                });
            }
        }