Пример #1
0
        public void EventDatastoreDeserializeShouldCorrectlyDeserializeTransactionPerformanceCalculatedEvent()
        {
            var configuration = new Mock <IConfigurationRegistry>();

            configuration.Setup(s => s.GetValue <string>("connection")).Returns("connection");

            var value = new EventDatastore("connection", "tableName", new Mock <IPerformanceMeasurementService>().Object, configuration.Object).Deserialize <IDomainEvent>(_transactionPerformanceCalculatedEvent);

            value.EventName.Should().Be("TransactionPerformanceCalculatedEvent");
            value.TimeStamp.Should().Be(DateTime.Parse("2018-01-25T10:07:17.0933351+01:00"));
            value.Id.Should().Be(Guid.Parse("b790f593-febf-424d-8f73-638f61a7f96e"));

            var castedValue = value as TransactionPerformanceCalculatedEvent;

            castedValue.Should().NotBeNull();

            castedValue.ProfitAbsolute.Should().Be((decimal)77.36);
            castedValue.ProfitPercentage.Should().Be((decimal)30.94);
            castedValue.ProfitMade.Should().BeTrue();
            castedValue.HoldingPeriod.Should().NotBeNull();
            castedValue.HoldingPeriod.IsIntradayTrade.Should().BeFalse();
            castedValue.HoldingPeriod.Period.Should().Be(TimeSpan.Parse("6.00:11:00"));
            castedValue.HoldingPeriod.StartDate.Should().Be(DateTime.Parse("2011-05-10T10:51:00"));
            castedValue.HoldingPeriod.EndDate.Should().Be(DateTime.Parse("2011-05-16T11:02:00"));
            castedValue.R.Should().Be((decimal)1.11);
        }
Пример #2
0
        public void MssqlEventDataStoreSerializeShouldCreateCorrectStringWhenCalledWithADomainEvent()
        {
            var configuration = new Mock <IConfigurationRegistry>();

            configuration.Setup(s => s.GetValue <string>("connection")).Returns("connection");

            var serializedEvent = new EventDatastore("connection", "tableName", new Mock <IPerformanceMeasurementService>().Object, configuration.Object).Serialize(_testEvent);

            serializedEvent.Should().Contain("StockTradingAnalysis.Data.MSSQL.Tests.EventDataStoreTests+TestEvent, StockTradingAnalysis.Data.MSSQL.Tests");
            serializedEvent.Should().Contain("Name");
            serializedEvent.Should().Contain("WKN");
            serializedEvent.Should().Contain("Type");
            serializedEvent.Should().Contain("long");
            serializedEvent.Should().Contain("TestEvent");
            serializedEvent.Should().Contain("0");
        }
Пример #3
0
        public void MssqlEventDataStoreDeserializeShouldCreateCorrectDomainEventWhenCalledWithAValidString()
        {
            var configuration = new Mock <IConfigurationRegistry>();

            configuration.Setup(s => s.GetValue <string>("connection")).Returns("connection");

            var deserializedEvent = new EventDatastore("connection", "tableName", new Mock <IPerformanceMeasurementService>().Object, configuration.Object).Deserialize <TestEvent>(_testEventSerialized);

            deserializedEvent.AggregateId.Should().Be(Guid.Parse("b02386b2-0884-4143-9a1c-3d508c572bb4"));
            deserializedEvent.Id.Should().Be(Guid.Parse("be02c64a-2f9c-43b1-af21-1140f94f6ba4"));
            deserializedEvent.TimeStamp.Should().Be(DateTime.Parse("2018-01-23T17:06:42.418107+01:00"));
            deserializedEvent.LongShort.Should().Be("long");
            deserializedEvent.Name.Should().Be("Name");
            deserializedEvent.Type.Should().Be("Type");
            deserializedEvent.Wkn.Should().Be("WKN");
            deserializedEvent.AggregateType.Should().Be(typeof(TestAggregate));
            deserializedEvent.EventName.Should().Be("TestEvent");
            deserializedEvent.Version.Should().Be(0);
        }