Line data Source code
1 : using System;
2 : using System.Collections.Generic;
3 : using System.Diagnostics;
4 : using cdmdotnet.Logging;
5 : using cdmdotnet.Logging.Configuration;
6 : using cdmdotnet.StateManagement.Threaded;
7 : using Cqrs.Azure.BlobStorage.DataStores;
8 : using Cqrs.Azure.ServiceBus.Tests.Unit;
9 : using Cqrs.Configuration;
10 : using NUnit.Framework;
11 : using TestClass = NUnit.Framework.TestFixtureAttribute;
12 : using TestMethod = NUnit.Framework.TestAttribute;
13 : using TestInitialize = NUnit.Framework.SetUpAttribute;
14 : using TestCleanup = NUnit.Framework.TearDownAttribute;
15 : using TestContext = System.Object;
16 :
17 : namespace Cqrs.Azure.BlobStorage.Test.Integration
18 : {
19 : /// <summary>
20 : /// A series of tests on the <see cref="BlobStorageDataStore{TData}"/> class
21 : /// </summary>
22 : [TestClass]
23 : public class BlobStorageDataStoreTests
24 1 : {
25 : [TestMethod]
26 0 : public virtual void Save_ValidProjectionView_ProjectionViewCanBeRetreived()
27 : {
28 : // Arrange
29 : var correlationIdHelper = new CorrelationIdHelper(new ThreadedContextItemCollectionFactory());
30 : correlationIdHelper.SetCorrelationId(Guid.NewGuid());
31 : var logger = new ConsoleLogger(new LoggerSettingsConfigurationSection(), correlationIdHelper);
32 : var dataStore = new BlobStorageDataStore<TestEvent>(logger, new BlobStorageDataStoreConnectionStringFactory(new ConfigurationManager(), logger));
33 :
34 : var event1 = new TestEvent
35 : {
36 : Rsn = Guid.NewGuid(),
37 : Id = Guid.NewGuid(),
38 : CorrelationId = correlationIdHelper.GetCorrelationId(),
39 : Frameworks = new List<string> { "Test 1" },
40 : TimeStamp = DateTimeOffset.UtcNow
41 : };
42 :
43 : // Act
44 : dataStore.Add(event1);
45 :
46 : // Assert
47 : var timer = new Stopwatch();
48 : timer.Start();
49 : TestEvent view = dataStore.GetByName(event1.Rsn);
50 : timer.Stop();
51 : Console.WriteLine("Load operation took {0}", timer.Elapsed);
52 : Assert.IsNotNull(view);
53 : Assert.AreEqual(event1.Id, view.Id);
54 : }
55 : }
56 : }
|