Exemplo n.º 1
0
        public void PreviousValueIsDefaultAfterRoundTrip()
        {
            /*
             * We don't want to serialize the Previous Value to the event store/stream, but we also
             * want to handle accessing the property gracefully
             */
            EntityCreatedEvent evt = new EntityCreatedEvent(nameof(Account), Guid.NewGuid().ToString());

            evt.AddChange("Decimal", FieldChange.Create <decimal>(500M, 100000M));
            evt.AddChange("Enum", FieldChange.Create <BudgetingTypes>(BudgetingTypes.OffBudget, BudgetingTypes.OnBudget));
            evt.AddChange("String", FieldChange.Create <string>(default(string), "Test"));
            evt.AddChange("Date", FieldChange.Create <DateTime>(default(DateTime), DateTime.Now));


            EntityCreatedEvent roundTripEvent = EventStreamRoundTripEvent(evt);

            Assert.That(roundTripEvent.Changes["Decimal"].PreviousValue, Is.EqualTo(default(decimal)));
            Assert.That(roundTripEvent.Changes["Enum"].PreviousValue, Is.EqualTo(default(BudgetingTypes)));
            Assert.That(roundTripEvent.Changes["String"].PreviousValue, Is.EqualTo(default(string)));
            Assert.That(roundTripEvent.Changes["Date"].PreviousValue, Is.EqualTo(default(DateTime)));
        }
Exemplo n.º 2
0
        public void EventStreamCanRoundTripFields()
        {
            EntityCreatedEvent evt = new EntityCreatedEvent(nameof(Account), Guid.NewGuid().ToString());

            evt.AddChange("Decimal", FieldChange.Create <decimal>(default(decimal), 100000M));
            evt.AddChange("Enum", FieldChange.Create <BudgetingTypes>(default(BudgetingTypes), BudgetingTypes.OnBudget));
            evt.AddChange("String", FieldChange.Create <string>(default(string), "Test"));
            evt.AddChange("Date", FieldChange.Create <DateTime>(default(DateTime), DateTime.Now));

            EntityCreatedEvent roundTripEvent = EventStreamRoundTripEvent(evt);

            Assert.That(roundTripEvent.Changes["Decimal"].NewValue.GetType(), Is.EqualTo(evt.Changes["Decimal"].NewValue.GetType()));
            Assert.That(roundTripEvent.Changes["Decimal"].NewValue, Is.EqualTo(evt.Changes["Decimal"].NewValue));

            Assert.That(roundTripEvent.Changes["Enum"].NewValue.GetType(), Is.EqualTo(evt.Changes["Enum"].NewValue.GetType()));
            Assert.That(roundTripEvent.Changes["Enum"].NewValue, Is.EqualTo(evt.Changes["Enum"].NewValue));

            Assert.That(roundTripEvent.Changes["String"].NewValue.GetType(), Is.EqualTo(evt.Changes["String"].NewValue.GetType()));
            Assert.That(roundTripEvent.Changes["String"].NewValue, Is.EqualTo(evt.Changes["String"].NewValue));

            Assert.That(roundTripEvent.Changes["Date"].NewValue.GetType(), Is.EqualTo(evt.Changes["Date"].NewValue.GetType()));
            Assert.That(roundTripEvent.Changes["Date"].NewValue, Is.EqualTo(evt.Changes["Date"].NewValue));
        }