Пример #1
0
        public virtual void Add_ValidProjectionView_ProjectionViewCanBeRetreived()
        {
            // Arrange
            var correlationIdHelper = new CorrelationIdHelper(new ThreadedContextItemCollectionFactory());

            correlationIdHelper.SetCorrelationId(Guid.NewGuid());
            var logger = new ConsoleLogger(new LoggerSettingsConfigurationSection(), correlationIdHelper);
            TableStorageDataStore <TestEvent> dataStore = CreateDataStore <TestEvent>(logger, new ConfigurationManager());

            var event1 = new TestEvent
            {
                Rsn           = Guid.NewGuid(),
                Id            = Guid.NewGuid(),
                CorrelationId = correlationIdHelper.GetCorrelationId(),
                Frameworks    = new List <string> {
                    "Test 1"
                },
                TimeStamp = DateTimeOffset.UtcNow
            };

            // Act
            dataStore.Add(event1);

            // Assert
            var timer      = new Stopwatch();
            var repository = new TableStorageRepository <TestQueryStrategy, TestQueryBuilder <TestEvent>, TestEvent>(() => dataStore, null);

            timer.Start();
            TestEvent view = repository.Load(event1.Rsn);

            timer.Stop();
            Console.WriteLine("Load operation took {0}", timer.Elapsed);
            Assert.IsNotNull(view);
            Assert.AreEqual(event1.Id, view.Id);
        }
Пример #2
0
        public virtual void Add_ValidProjectionEntityView_ProjectionEntityViewCanBeRetreived()
        {
            // Arrange
            var correlationIdHelper = new CorrelationIdHelper(new ThreadedContextItemCollectionFactory());

            correlationIdHelper.SetCorrelationId(Guid.NewGuid());
            var logger = new ConsoleLogger(new LoggerSettingsConfigurationSection(), correlationIdHelper);
            TableStorageDataStore <TestEntity> dataStore = CreateDataStore <TestEntity>(logger, new ConfigurationManager());

            var event1 = new TestEntity
            {
                Rsn  = Guid.NewGuid(),
                Name = "Name"
            };

            // Act
            dataStore.Add(event1);

            // Assert
            var timer      = new Stopwatch();
            var repository = new TableStorageRepository <TestQueryStrategy, TestQueryBuilder <TestEntity>, TestEntity>(() => dataStore, null);

            timer.Start();
            TestEntity view = repository.Load(event1.Rsn);

            timer.Stop();
            Console.WriteLine("Load operation took {0}", timer.Elapsed);
            Assert.IsNotNull(view);
            Assert.AreEqual(event1.Rsn, view.Rsn);
            Assert.AreEqual(event1.Name, view.Name);
        }
Пример #3
0
        public virtual void Update_ValidProjectionEntityView_ProjectionEntityViewCanBeRetreived()
        {
            // Arrange
            var correlationIdHelper = new CorrelationIdHelper(new ThreadedContextItemCollectionFactory());

            correlationIdHelper.SetCorrelationId(Guid.NewGuid());
            var logger = new ConsoleLogger(new LoggerSettingsConfigurationSection(), correlationIdHelper);
            TableStorageDataStore <TestEntity> dataStore = CreateDataStore <TestEntity>(logger, new ConfigurationManager());

            var event1 = new TestEntity
            {
                Rsn  = Guid.NewGuid(),
                Name = "Name1"
            };

            dataStore.Add(event1);

            // The repo disposes the datastore, so a copy is needed.
            TableStorageDataStore <TestEntity> repoDataStore = CreateDataStore <TestEntity>(logger, new ConfigurationManager());
            // DO NOT REMOVE/REFACTOR Closure modifier access thingee stuff...
            var        store      = repoDataStore;
            var        repository = new TableStorageRepository <TestQueryStrategy, TestQueryBuilder <TestEntity>, TestEntity>(() => store, null);
            TestEntity view       = repository.Load(event1.Rsn);

            view.Name = "Name2";

            // Act
            dataStore.Update(event1);

            // Assert
            var timer = new Stopwatch();

            timer.Start();
            // Refresh the data store due to disposal.
            repoDataStore = CreateDataStore <TestEntity>(logger, new ConfigurationManager());
            repository    = new TableStorageRepository <TestQueryStrategy, TestQueryBuilder <TestEntity>, TestEntity>(() => repoDataStore, null);
            view          = repository.Load(event1.Rsn);
            timer.Stop();
            Console.WriteLine("Load operation took {0}", timer.Elapsed);
            Assert.IsNotNull(view);
            Assert.AreEqual(event1.Rsn, view.Rsn);
            Assert.AreEqual(event1.Name, view.Name);
        }