public void Parse_EventCreationDateFieldIsNotDateTime_ErrorShouldBeReturned()
        {
            //prepare
            var bookingCreatedEvent = new IntergrationEventWithNonDateTimeEventCreationDate <BookingCreated>()
            {
                EventId           = Guid.NewGuid(),
                CorrelationId     = Guid.NewGuid(),
                EventCreationDate = 123,
                EventType         = "bookingCreated",
                Version           = "0.1",
                Content           = new BookingCreated()
                {
                    BookingName = "bookingName"
                }
            };

            //act
            IntergrationEventParsingResult result =
                DefaultIntergrationEventParser.Parse(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bookingCreatedEvent)));

            //check
            result.Success.Should().BeFalse();
            result.IntegrationEvent.Should().BeNull();
            result.Errors.First().Should().Be("EventCreationDate is not DateTime");
        }
        public void Parse_CorrelationIdFieldIsEmpty_SuccessShouldBeReturned()
        {
            //prepare
            var bookingCreatedEvent = new IntegrationEvent <BookingCreated>()
            {
                EventId           = Guid.NewGuid(),
                CorrelationId     = null,
                EventCreationDate = DateTime.UtcNow,
                EventType         = "bookingCreated",
                Version           = "0.1",
                Content           = new BookingCreated()
                {
                    BookingName = "bookingName"
                }
            };

            //act
            IntergrationEventParsingResult result =
                DefaultIntergrationEventParser.Parse(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bookingCreatedEvent)));

            //check
            result.Success.Should().BeTrue();
            result.IntegrationEvent.ShouldBeEquivalentTo(bookingCreatedEvent);
            result.Errors.Count.Should().Be(0);
        }
        public void Parse_VersionFieldIsMissed_ErrorShouldBeReturned()
        {
            //prepare
            var bookingCreatedEvent = new IntergrationEventWithoutVersion <BookingCreated>()
            {
                EventId           = Guid.NewGuid(),
                CorrelationId     = Guid.NewGuid(),
                EventCreationDate = DateTime.UtcNow,
                EventType         = "bookingcreated",
                Content           = new BookingCreated()
                {
                    BookingName = "bookingName"
                }
            };

            //act
            IntergrationEventParsingResult result =
                DefaultIntergrationEventParser.Parse(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bookingCreatedEvent)));

            //check
            result.Success.Should().BeFalse();
            result.IntegrationEvent.Should().BeNull();
            result.Errors.First().Should().Be("Version token is missed");
        }